From 1ab56c61bf97e303b6473a6396226c906358609a Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sat, 11 Mar 2023 13:11:10 -0300 Subject: [PATCH] Add src/sitemap.xml.erb --- Rules | 8 ++++++++ lib/nanoc/filters/strip.rb | 10 ++++++++++ src/sitemap.xml.erb | 26 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 lib/nanoc/filters/strip.rb create mode 100644 src/sitemap.xml.erb 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 %> +