Deploying to gh-pages from @ DGP-Studio/Snap.Hutao.Docs@18b46ebf3a 🚀

This commit is contained in:
Masterain98
2023-04-03 01:37:49 +00:00
parent 9c0601a9de
commit ae2c7871f1
297 changed files with 1414 additions and 1371 deletions

View File

@@ -3,63 +3,12 @@
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<meta http-equiv="refresh" content="0; url=/zh/features/real-time-notes.html">
<link rel="canonical" href="/zh/features/real-time-notes.html">
<title>Redirecting...</title>
<script>
const { hash, origin, pathname } = window.location;
const { languages } = window.navigator;
const anchor = hash.substr(1);
const localeConfig = {"/en/":["en-US","en-UK","en"],"/zh/":["zh-CN","zh-TW","zh"]};
const availableLocales = ["/en/","/zh/"];
const defaultLocale = "/en/";
const defaultBehavior = "defaultLocale"
let localePath = null;
// get matched locale
findLanguage:
for (const lang of languages)
for (const [path, langs] of Object.entries(localeConfig))
if (langs.includes(lang)) {
if (!availableLocales.includes(path))
continue;
localePath = path;
break findLanguage;
}
// default link
const defaultLink = defaultLocale? `${origin}${defaultLocale}${pathname.substring(1)}${anchor?`#${anchor}`:""}`: null;
// a locale matches
if (localePath) {
const localeLink = `${origin}${localePath}${pathname.substring(1)}${anchor?`#${anchor}`:""}`;
if (availableLocales.includes(localePath)) {
location.href = localeLink;
}
// the page does not exist
else {
// locale homepage
if (defaultBehavior === "homepage") {
location.href = `${origin}${localePath}`;
}
// default locale page
else if (defaultBehavior === "defaultLocale" && defaultLink) {
location.href = defaultLink;
}
// as is to get a 404 page of that locale
else {
location.href = localeLink;
}
}
}
// we have a default page
else if (defaultLink) {
location.href = defaultLink;
}
else {
location.href = `${origin}/404.html`;
}
const anchor = window.location.hash.substr(1);
location.href = `/zh/features/real-time-notes.html${anchor?`#${anchor}`:""}`;
</script>
</head>
<body>