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 333616d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs/docs/.vitepress/theme/Layout.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
<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=/`
}, {
immediate: false,
})
</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
2 changes: 2 additions & 0 deletions docs/docs/public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/guide/* /en/guide/:splat 302! Language=en
/develop/* /en/develop/:splat 302! Language=en

0 comments on commit 333616d

Please sign in to comment.