mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.Docs.git
synced 2025-11-19 21:16:31 +08:00
Deploying to gh-pages from @ DGP-Studio/Snap.Hutao.Docs@284dbbe58d 🚀
This commit is contained in:
69
development/symposium2.html
Normal file
69
development/symposium2.html
Normal file
@@ -0,0 +1,69 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="robots" content="noindex">
|
||||
<title>Redirecting...</title>
|
||||
<script>
|
||||
const { hash, origin, pathname } = window.location;
|
||||
const routePath = pathname.substring(1);
|
||||
const { languages } = window.navigator;
|
||||
const anchor = hash.substring(1);
|
||||
|
||||
const localeConfig = {"0":["/en/",["en-US","en-UK","en"]],"1":["/zh/",["zh-CN","zh-TW","zh"]],"/zh/":["zh-CN"],"/en/":["en-US"]};
|
||||
const availableLocales = ["/zh/"];
|
||||
const defaultLocale = availableLocales.pop();
|
||||
const defaultBehavior = "defaultLocale"
|
||||
|
||||
let matchedLocalePath = null;
|
||||
|
||||
// get matched locale
|
||||
findLanguage:
|
||||
for (const lang of languages)
|
||||
for (const [localePath, langs] of Object.entries(localeConfig))
|
||||
if (langs.includes(lang)) {
|
||||
if (!availableLocales.includes(localePath))
|
||||
continue;
|
||||
matchedLocalePath = localePath;
|
||||
break findLanguage;
|
||||
}
|
||||
|
||||
// default link
|
||||
const defaultLink = defaultLocale? `${origin}${defaultLocale}${routePath}${anchor? `#${anchor}`: ""}`: null;
|
||||
|
||||
// a locale matches
|
||||
if (matchedLocalePath) {
|
||||
const localeLink = `${origin}${matchedLocalePath}${routePath}${anchor? `#${anchor}`: ""}`;
|
||||
|
||||
if (availableLocales.includes(matchedLocalePath)) {
|
||||
location.href = localeLink;
|
||||
}
|
||||
// the page does not exist
|
||||
else {
|
||||
// locale homepage
|
||||
if (defaultBehavior === "homepage") {
|
||||
location.href = `${origin}${matchedLocalePath}`;
|
||||
}
|
||||
// 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`;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting...</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user