Skip to content

Commit

Permalink
feat: correct i18n redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
altrusl committed Nov 15, 2023
1 parent d31883a commit bd17923
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions docs/.vitepress/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import nav_ru from "./nav.ru";
import sidebar_en from "./sidebar.en";
import sidebar_ru from "./sidebar.ru";
import sidebar_book_ru from "./sidebar.book.ru";
import sidebar_vue_webapp_ru from "./sidebar.vue-webapp.ru";
import sidebar_vue_webapp_en from "./sidebar.vue-webapp.en";

// https://vitepress.dev/reference/site-config
export default defineConfig({
Expand All @@ -12,14 +14,21 @@ export default defineConfig({
root: {
lang: "ru",
label: "Русский",
themeConfig: {
nav: nav_ru,
sidebar: {
"/": sidebar_ru,
"/book/": sidebar_book_ru,
"/vue-webapp/": sidebar_vue_webapp_ru,
},
},
head: [
[
"script",
{},
`const init = localStorage.getItem("vue-faq-init") ?? false;
localStorage.setItem("vue-faq-init", true);
const isGoogleBot = window.navigator.userAgent.includes('googlebot');
console.log("/en" + window.location.pathname);
if (navigator.language != "ru-RU" && !init && !isGoogleBot) document.location="/en" + window.location.pathname;
`,
],
Expand All @@ -39,7 +48,10 @@ export default defineConfig({
label: "English",
themeConfig: {
nav: nav_en,
sidebar: sidebar_en,
sidebar: {
"/en/": sidebar_en,
"/en/vue-webapp/": sidebar_vue_webapp_en,
},
},
head: [
["script", { async: "", src: "https://www.googletagmanager.com/gtag/js?id=G-JCCRGKJ88B" }],
Expand Down Expand Up @@ -72,12 +84,7 @@ export default defineConfig({
search: {
provider: "local",
},
// https://vitepress.dev/reference/default-theme-config
nav: nav_ru,
sidebar: {
"/": sidebar_ru,
"/book/": sidebar_book_ru,
},
// https://vitepress.dev/reference/default-theme-config
socialLinks: [
{ icon: "github", link: "https://github.com/vuesence/vue-faq" },
{ icon: {svg: '<svg xmlns="http://www.w3.org/2000/svg"><g><text font-weight="bold" xml:space="preserve" font-size="18" id="svg_1" y="16" x="8" fill="currentColor">Star it!</text></g></svg>'}, link: "https://github.com/vuesence/vue-faq" }
Expand Down

0 comments on commit bd17923

Please sign in to comment.