Remove redirect from /en/1/ to /en/al-fatihah/
Rather than redirect /en/1/ to /en/al-fatihah/, render the surah stream instead. A canonical `link` tag is included for the benefit of search engines to differentiate between duplicates. Preference is given to /en/al-fatihah/ over /en/1/.
This commit is contained in:
parent
a6b55b64b7
commit
a2fc33bb7c
5 changed files with 28 additions and 45 deletions
1
Rules
1
Rules
|
@ -82,7 +82,6 @@ require_rules "nanoc/rules/pages/surah/redirect"
|
||||||
require_rules "nanoc/rules/pages/surah/stream", {locales:, i18n:, slugs:}
|
require_rules "nanoc/rules/pages/surah/stream", {locales:, i18n:, slugs:}
|
||||||
require_rules "nanoc/rules/pages/surah/index", {locales:, i18n:}
|
require_rules "nanoc/rules/pages/surah/index", {locales:, i18n:}
|
||||||
require_rules "nanoc/rules/pages/surah/random", {locales:, i18n:, slugs:}
|
require_rules "nanoc/rules/pages/surah/random", {locales:, i18n:, slugs:}
|
||||||
require_rules "nanoc/rules/pages/surah/id_redirect", {locales:, i18n:, slugs:}
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Defaults
|
# Defaults
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
##
|
|
||||||
# Rules for a redirect from a surah id to a surah name
|
|
||||||
# (eg /en/1/ -> /en/al-fatihah/)
|
|
||||||
|
|
||||||
1.upto(114) do |id|
|
|
||||||
locales.each do |locale|
|
|
||||||
compile "/html/pages/surah/id_redirect.html.erb", rep: "redirect_id/#{locale}/#{id}" do
|
|
||||||
slug = slugs[id]
|
|
||||||
redirect_url = "https://al-quran.reflectslight.io/#{locale}/#{slug}/"
|
|
||||||
title = i18n[locale].TheNobleQuran
|
|
||||||
filter(:erb, {locals: {title:, redirect_url:, locale:}})
|
|
||||||
write("/#{locale}/#{id}/index.html")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -14,12 +14,23 @@ compile "/*/*/surah.json" do
|
||||||
end
|
end
|
||||||
|
|
||||||
Ryo.each(slugs) do |id, slug|
|
Ryo.each(slugs) do |id, slug|
|
||||||
|
writer = ->(locale, identifier:) do
|
||||||
|
name = i18n[locale].surahs.names[id.to_i - 1]
|
||||||
|
context = Ryo.from(
|
||||||
|
filename: "stream.html.erb",
|
||||||
|
locale:,
|
||||||
|
locales:,
|
||||||
|
surah: {id:, name:, slug:}
|
||||||
|
)
|
||||||
|
filter(:erb, locals: {context:})
|
||||||
|
write "/#{locale}/#{identifier}/index.html"
|
||||||
|
end
|
||||||
locales.each do |locale|
|
locales.each do |locale|
|
||||||
compile "/html/pages/surah/stream.html.erb", rep: "/#{locale}/#{slug}/index.html" do
|
compile "/html/pages/surah/stream.html.erb", rep: "/#{locale}/#{slug}/index.html" do
|
||||||
name = i18n[locale].surahs.names[id.to_i - 1]
|
instance_exec(locale, identifier: slug, &writer)
|
||||||
context = Ryo.from(filename: "stream.html.erb", locale:, surah: {id:, name:, slug:})
|
end
|
||||||
filter(:erb, locals: {context:})
|
compile "/html/pages/surah/stream.html.erb", rep: "/#{locale}/#{id}/index.html" do
|
||||||
write "/#{locale}/#{slug}/index.html"
|
instance_exec(locale, identifier: id, &writer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title><%= title %></title>
|
|
||||||
<link rel="canonical" href="<%= redirect_url %>">
|
|
||||||
<link rel="icon" href="/favicon.png">
|
|
||||||
<noscript>
|
|
||||||
<meta http-equiv="refresh" content="0; url=<%= redirect_url %>">
|
|
||||||
</noscript>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script>
|
|
||||||
(function() {
|
|
||||||
var el = document.createElement("meta");
|
|
||||||
var url = "<%= redirect_url %>" + document.location.search;
|
|
||||||
el.setAttribute("http-equiv", "refresh");
|
|
||||||
el.setAttribute("content", "0; url=" + url);
|
|
||||||
document.head.append(el);
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -6,6 +6,19 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="description" content="<%= t(context.locale, 'meta.stream.description') %>">
|
<meta name="description" content="<%= t(context.locale, 'meta.stream.description') %>">
|
||||||
|
<link
|
||||||
|
rel="canonical"
|
||||||
|
hreflang="<%= context.locale %>"
|
||||||
|
href="/<%= context.locale %>/<%= context.surah.slug %>/"
|
||||||
|
/>
|
||||||
|
<% context.locales.each do |locale| %>
|
||||||
|
<link
|
||||||
|
rel="alternate"
|
||||||
|
type="text/html"
|
||||||
|
hreflang="<%= locale %>"
|
||||||
|
href="/<%= locale %>/<%= context.surah.slug %>/"
|
||||||
|
/>
|
||||||
|
<% end -%>
|
||||||
<%= opengraph(context) %>
|
<%= opengraph(context) %>
|
||||||
<link rel="icon" href="/favicon.png">
|
<link rel="icon" href="/favicon.png">
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Reference in a new issue