diff --git a/.vitepress/config/index.ts b/.vitepress/config/index.ts index 3610151..d3ba884 100644 --- a/.vitepress/config/index.ts +++ b/.vitepress/config/index.ts @@ -11,6 +11,7 @@ import { fileURLToPath, URL } from 'node:url' import { telegram } from '../../website/icons' import { normalize } from 'vitepress/dist/client/shared' import { tabsMarkdownPlugin } from "vitepress-plugin-tabs" +import pluginRewriteAll from 'vite-plugin-rewrite-all'; import shortcode_plugin from "markdown-it-shortcode-tag" import shortcodes from "./shortcodes" @@ -51,6 +52,7 @@ export default defineConfigWithTheme({ config (md) { addPlugins(md) md.use(tabsMarkdownPlugin) + md.use(pluginRewriteAll) md.use(shortcode_plugin, shortcodes) }, }, diff --git a/.vitepress/theme/index.ts b/.vitepress/theme/index.ts index 9113c1e..ad085c9 100644 --- a/.vitepress/theme/index.ts +++ b/.vitepress/theme/index.ts @@ -1,5 +1,5 @@ -import { type Router, inBrowser } from 'vitepress' -import { type App, watch, defineComponent } from 'vue' +import { type Router, inBrowser, useData } from 'vitepress' +import { type App, watch, defineComponent, watchEffect } from 'vue' import { createZoom } from './composables/zoom' import { enhanceAppWithTabs } from "vitepress-plugin-tabs/client" import analytics from "./plugins/analytics" @@ -12,6 +12,15 @@ export default { extends: DefaultTheme, Layout: Layout, + setup() { + const { lang } = useData() + watchEffect(() => { + if (inBrowser) { + document.cookie = `nf_lang=${lang.value}; expires=Mon, 1 Jan 2024 00:00:00 UTC; path=/` + } + }) + }, + enhanceApp({ app, router }: { app: App, router: Router }) { enhanceAppWithTabs(app) createZoom(app, router) diff --git a/package.json b/package.json index 3bbf847..361508e 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "stylus": "0.60.0", "transliteration": "^2.3.5", "vue3-carousel": "0.3.1", + "vite-plugin-rewrite-all": "1.0.1", "vitepress": "^1.0.0-rc.20", "vitepress-plugin-tabs": "0.4.1", "vue": "^3.3.4",