Skip to content

Commit

Permalink
chore(docs): add support for auto-redirect to language-specific docs
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Sep 18, 2024
1 parent 349eb6f commit 29b19c6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/docs/.vitepress/theme/Layout.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<script setup>
import DefaultTheme from 'vitepress/theme'
import { onMounted } from 'vue'
import { inBrowser, useData } from 'vitepress'
import { watchEffect } from 'vue'
import './style.scss'
const { Layout } = DefaultTheme
const { lang } = useData()
watchEffect(() => {
if (inBrowser) document.cookie = `nf_lang=${lang.value}; expires=Mon, 1 Jan 2030 00:00:00 UTC; path=/`
})
</script>

<template>
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/public/_headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/assets/*
cache-control: max-age=31536000
cache-control: immutable
7 changes: 7 additions & 0 deletions docs/docs/public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/guide/* /en/guide/:splat 302! Language=en
/guide/* /guide/:splat 302! Language=zh
/guide/* /en/guide/:splat 302!

/develop/* /en/develop/:splat 302! Language=en
/develop/* /develop/:splat 302! Language=zh
/develop/* /en/develop/:splat 302!

0 comments on commit 29b19c6

Please sign in to comment.