-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploying to gh-pages from @ 72b8c9f 🚀
- Loading branch information
Showing
46 changed files
with
2,032 additions
and
1,266 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = {"/en/":["en-US"],"/zh/":["zh-CN"]}; | ||
const availableLocales = ["/en/","/zh/"]; | ||
const defaultLocale = "/zh/"; | ||
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = {"/en/":["en-US"],"/zh/":["zh-CN"]}; | ||
const availableLocales = ["/en/","/zh/"]; | ||
const defaultLocale = "/zh/"; | ||
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> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.