Redirect to the surah index from the root path

When a browser visits the root path (/) then redirect to
the surah index with the appropriate locale (eg /en/, /ar/).
This commit is contained in:
0x1eef 2023-03-08 00:20:53 -03:00
parent c3e84202a2
commit c892d88e65
4 changed files with 24 additions and 5 deletions

View file

@ -4,11 +4,6 @@
# Contains rules that are related to RandomRedirect.html.erb
# in one way or another
compile "/html/RandomRedirect.html.erb" do
filter(:erb)
write("/index.html")
end
compile "/html/redirect-to-surah-slug.html.erb" do
filter(:erb)
1.upto(114) do |surahno|

View file

@ -4,6 +4,16 @@
# Contains rules that are related to TheSurahIndex in one
# way or another.
compile "/html/surah/index/redirect.html.erb" do
filter(:erb)
write("/index.html")
end
compile "/js/surah/index/redirect.ts" do
filter(:webpack)
write("/js/surah/index/redirect.js")
end
compile "/surahs.json" do
write "/surahs.json"
end

View file

@ -0,0 +1,8 @@
<!DOCTYPE html>
<head>
<title></title>
</head>
<body>
<script src="/js/surah/index/redirect.js"></script>
</body>
</html>

View file

@ -0,0 +1,6 @@
import { Locale } from 'lib/Locale';
(function(window, location) {
const locale = Locale(window).fromBrowser();
location.replace(`/${locale}/`);
})(window, location);