Fix bug in redirect.ts

This commit is contained in:
0x1eef 2024-05-24 15:56:52 -03:00
parent d9b72605fe
commit 7d8867e991
2 changed files with 12 additions and 2 deletions

View file

@ -2,8 +2,17 @@
desc "Run CI tasks"
task :ci do
##
# format
sh "bundle exec rubocop"
sh "npm exec eslint -- src/js/"
sh "npm exec prettier -- --check src/js/"
##
# tsc
sh "npm run tsc"
##
# build
Bundler.with_original_env { sh "buildenv=production rake nanoc:clean nanoc:build" }
end

View file

@ -1,9 +1,10 @@
import { Quran, TLocale } from "Quran";
import { Quran } from "Quran";
(function () {
const defaultl = "en";
const locales = Quran.locales.map(l => l.name);
const locale =
navigator.languages
.map(s => s.slice(0, 2).toLowerCase())
.find(s => Quran.locales.includes(s as TLocale)) || defaultl;
.find(s => locales.includes(s)) || defaultl;
location.replace(`/${locale}/`);
})();