Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
jiazengp committed Jul 29, 2023
1 parent 348bc99 commit c215915
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
10 changes: 3 additions & 7 deletions .vitepress/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export default defineConfig({
srcExclude: [],
scrollOffset: 'header',
cleanUrls: true,
sitemap: {
hostname: 'https://yuanshen.site',
},
themeConfig: {
search: {
provider: 'local',
Expand Down Expand Up @@ -332,13 +335,6 @@ export default defineConfig({
})
},
buildEnd: (config) => {
const sitemap = new SitemapStream({
hostname: 'https://yuanshen.site/docs/',
})
const writeStream = createWriteStream(resolve(config.outDir, 'sitemap.xml'))
sitemap.pipe(writeStream)
links.forEach((link) => sitemap.write(link))
sitemap.end()
genFeed(config)
},
})
18 changes: 16 additions & 2 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { onMounted, watch, nextTick, defineAsyncComponent, h } from 'vue'
import { useRoute, inBrowser } from 'vitepress'
import {
onMounted,
watch,
nextTick,
defineAsyncComponent,
h,
watchEffect,
} from 'vue'
import { useRoute, inBrowser, useData } from 'vitepress'
import mediumZoom from 'medium-zoom'
import DefaultTheme from 'vitepress/theme-without-fonts'
import Link from './components/Link.vue'
Expand Down Expand Up @@ -32,6 +39,7 @@ export default {
},
setup() {
const route = useRoute()
const { lang } = useData()
const initZoom = () => {
mediumZoom('.main img:not(.no-zoomable)', {
background: 'var(--vp-c-bg)',
Expand All @@ -48,5 +56,11 @@ export default {
initZoom()
})
)

watchEffect(() => {
if (inBrowser) {
document.cookie = `nf_lang=${lang.value}; expires=Mon, 1 Jan 2024 00:00:00 UTC; path=/`
}
})
},
}

0 comments on commit c215915

Please sign in to comment.