diff --git a/Rules b/Rules index 0fb4916..7da91f6 100644 --- a/Rules +++ b/Rules @@ -60,6 +60,14 @@ compile "/css/webpackage.scss" do write(nil) end +## +# /sitemap.xml +compile "/sitemap.xml.erb" do + filter(:erb, locals: {locales:, surah_id_to_name:}) + filter(:strip) + write("/sitemap.xml") +end + ## # Defaults compile("/**/*") { write(nil) } diff --git a/lib/nanoc/filters/strip.rb b/lib/nanoc/filters/strip.rb new file mode 100644 index 0000000..40d275b --- /dev/null +++ b/lib/nanoc/filters/strip.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class Nanoc::Filters::Strip < Nanoc::Filter + identifier :strip + type text: :text + + def run(content, options = {}) + content.each_line.reject { _1.strip.empty? }.join + end +end diff --git a/src/sitemap.xml.erb b/src/sitemap.xml.erb new file mode 100644 index 0000000..c44f42e --- /dev/null +++ b/src/sitemap.xml.erb @@ -0,0 +1,26 @@ + + + <% locales.each do |locale| %> + + https://al-quran.reflectslight.io/<%= locale %>/ + <% locales.each do |locale| %> + + <% end %> + + <% Ryo.each(surah_id_to_name) do |_id, name| %> + + https://al-quran.reflectslight.io/<%= locale %>/<%= name %>/ + <% locales.each do |locale| %> + + <% end %> + + <% end %> + <% end %> +