Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Aug 16, 2023
1 parent 874a759 commit 691496c
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import { createWriteStream } from 'node:fs'
import { resolve } from 'node:path'
import { SitemapStream } from 'sitemap'
import { defineConfig } from 'vitepress'

const links = []

export default defineConfig({
lastUpdated: true,
lang: 'zh-CN',
sitemap: {
hostname: 'https://virt.spiritlhl.net',
transformItems(items) {
return items.filter((item) => !item.url.includes('migration'))
transformHtml: (_, id, { pageData }) => {
if (!/[\\/]404\.html$/.test(id)) {
links.push({
url: pageData.relativePath.replace(/\/index\.md$/, '/').replace(/\.md$/, '.html'),
lastmod: pageData.lastUpdated,
})
}
},
buildEnd: async ({ outDir }) => {
const sitemap = new SitemapStream({
hostname: 'https://virt.spiritlhl.net/'
})
const writeStream = createWriteStream(resolve(outDir, 'sitemap.xml'))
sitemap.pipe(writeStream)
links.forEach((link) => sitemap.write(link))
sitemap.end()
await new Promise((r) => writeStream.on('finish', r))
},
head: [
['link', { rel: 'icon', href: 'https://raw.githubusercontent.com/spiritlhls/pages/main/logo.png' }],
['meta', { name: 'google-site-verification', content: 'wdrGBim_2XmtMrqxivze70saMiPQAiOhpmN3KAWb0Sw' }],
Expand Down

0 comments on commit 691496c

Please sign in to comment.