Re-implement id_redirect.ts without a JS redirect
This commit is contained in:
parent
3f3032dfcb
commit
c1d23f27c7
3 changed files with 5 additions and 21 deletions
|
@ -8,13 +8,10 @@
|
|||
1.upto(114) do |id|
|
||||
locales.each do |locale|
|
||||
compile "/html/pages/surah/id_redirect.html.erb", rep: "redirect_id/#{locale}/#{id}" do
|
||||
filter(:erb, locals: {locale:, surah_name: surah_id_to_name[id]})
|
||||
surah_name = surah_id_to_name[id]
|
||||
redirect_url = "https://al-quran.reflectslight.io/#{locale}/#{surah_name}/"
|
||||
filter(:erb, {locals: {redirect_url:}})
|
||||
write("/#{locale}/#{id}/index.html")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
compile "/js/pages/surah/id_redirect.ts" do
|
||||
filter(:webpack)
|
||||
write("/js/pages/surah/id_redirect.js")
|
||||
end
|
||||
|
|
|
@ -2,12 +2,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Al-Quran: redirect</title>
|
||||
<link
|
||||
rel="canonical"
|
||||
href="https://al-quran.reflectslight.io/<%= locale %>/<%= surah_name %>/">
|
||||
<link rel="canonical" href="<%= redirect_url %>">
|
||||
<meta http-equiv="refresh" content="0; url=<%= redirect_url %>">
|
||||
</head>
|
||||
<body>
|
||||
<%= inline_json('/slugs.json') %>
|
||||
<script src="/js/pages/surah/id_redirect.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
(function () {
|
||||
const [locale, surahId] = location.pathname
|
||||
.split('/')
|
||||
.filter(function (s) { return s.length; })
|
||||
.slice(-2);
|
||||
const el: HTMLElement = document.querySelector('.json.slugs')!;
|
||||
const slugs = JSON.parse(el.innerText);
|
||||
const path = ['', locale, slugs[surahId]].join('/');
|
||||
location.replace([path, location.search].join(''));
|
||||
})();
|
Loading…
Reference in a new issue