Add src/sitemap.xml.erb
This commit is contained in:
parent
549e7ef905
commit
1ab56c61bf
3 changed files with 44 additions and 0 deletions
8
Rules
8
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) }
|
||||
|
|
10
lib/nanoc/filters/strip.rb
Normal file
10
lib/nanoc/filters/strip.rb
Normal file
|
@ -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
|
26
src/sitemap.xml.erb
Normal file
26
src/sitemap.xml.erb
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
||||
xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
||||
<% locales.each do |locale| %>
|
||||
<url>
|
||||
<loc>https://al-quran.reflectslight.io/<%= locale %>/</loc>
|
||||
<% locales.each do |locale| %>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="<%= locale %>"
|
||||
href="https://al-quran.reflectslight.io/<%= locale %>/"/>
|
||||
<% end %>
|
||||
</url>
|
||||
<% Ryo.each(surah_id_to_name) do |_id, name| %>
|
||||
<url>
|
||||
<loc>https://al-quran.reflectslight.io/<%= locale %>/<%= name %>/</loc>
|
||||
<% locales.each do |locale| %>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="<%= locale %>"
|
||||
href="https://al-quran.reflectslight.io/<%= locale %>/<%= name %>/"/>
|
||||
<% end %>
|
||||
</url>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</urlset>
|
Loading…
Reference in a new issue