Skip to content

Commit

Permalink
Deploy to GitHub pages
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Jul 25, 2024
0 parents commit d887f7f
Show file tree
Hide file tree
Showing 400 changed files with 28,252 additions and 0 deletions.
69 changes: 69 additions & 0 deletions 01-hello-world/hello-world.html
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(19);
const { languages } = window.navigator;
const anchor = hash.substring(1);

const localeConfig = {"/en/":["en-US"],"/zh/":["zh-CN"]};
const availableLocales = ["/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}/modern-cpp-primer${defaultLocale}${routePath}${anchor? `#${anchor}`: ""}`: null;

// a locale matches
if (matchedLocalePath) {
const localeLink = `${origin}/modern-cpp-primer${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}/modern-cpp-primer${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}/modern-cpp-primer/404.html`;
}
</script>
</head>
<body>
<p>Redirecting...</p>
</body>
</html>
69 changes: 69 additions & 0 deletions 01-hello-world/id-and-keyword.html
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(19);
const { languages } = window.navigator;
const anchor = hash.substring(1);

const localeConfig = {"/en/":["en-US"],"/zh/":["zh-CN"]};
const availableLocales = ["/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}/modern-cpp-primer${defaultLocale}${routePath}${anchor? `#${anchor}`: ""}`: null;

// a locale matches
if (matchedLocalePath) {
const localeLink = `${origin}/modern-cpp-primer${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}/modern-cpp-primer${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}/modern-cpp-primer/404.html`;
}
</script>
</head>
<body>
<p>Redirecting...</p>
</body>
</html>
69 changes: 69 additions & 0 deletions 01-hello-world/index.html
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(19);
const { languages } = window.navigator;
const anchor = hash.substring(1);

const localeConfig = {"/en/":["en-US"],"/zh/":["zh-CN"]};
const availableLocales = ["/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}/modern-cpp-primer${defaultLocale}${routePath}${anchor? `#${anchor}`: ""}`: null;

// a locale matches
if (matchedLocalePath) {
const localeLink = `${origin}/modern-cpp-primer${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}/modern-cpp-primer${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}/modern-cpp-primer/404.html`;
}
</script>
</head>
<body>
<p>Redirecting...</p>
</body>
</html>
69 changes: 69 additions & 0 deletions 01-hello-world/literals.html
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(19);
const { languages } = window.navigator;
const anchor = hash.substring(1);

const localeConfig = {"/en/":["en-US"],"/zh/":["zh-CN"]};
const availableLocales = ["/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}/modern-cpp-primer${defaultLocale}${routePath}${anchor? `#${anchor}`: ""}`: null;

// a locale matches
if (matchedLocalePath) {
const localeLink = `${origin}/modern-cpp-primer${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}/modern-cpp-primer${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}/modern-cpp-primer/404.html`;
}
</script>
</head>
<body>
<p>Redirecting...</p>
</body>
</html>
69 changes: 69 additions & 0 deletions 01-hello-world/punctuators.html
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(19);
const { languages } = window.navigator;
const anchor = hash.substring(1);

const localeConfig = {"/en/":["en-US"],"/zh/":["zh-CN"]};
const availableLocales = ["/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}/modern-cpp-primer${defaultLocale}${routePath}${anchor? `#${anchor}`: ""}`: null;

// a locale matches
if (matchedLocalePath) {
const localeLink = `${origin}/modern-cpp-primer${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}/modern-cpp-primer${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}/modern-cpp-primer/404.html`;
}
</script>
</head>
<body>
<p>Redirecting...</p>
</body>
</html>
Loading

0 comments on commit d887f7f

Please sign in to comment.