-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.ts
More file actions
64 lines (57 loc) · 1.67 KB
/
config.ts
File metadata and controls
64 lines (57 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { viteBundler } from '@vuepress/bundler-vite';
import { defineUserConfig } from "vuepress";
import theme from "./theme.js";
import { releaseVarsPlugin, replaceReleaseTokens } from "./markdown/releaseVarsPlugin.js";
import { getReleaseFromPath } from "./data/releases.js";
export default defineUserConfig({
host: "127.0.0.1",
base: "/",
head: [['link', { rel: 'icon', href: '/photos/home/logo-small.svg' }]],
bundler: viteBundler({
viteOptions: {},
vuePluginOptions: {},
}),
/*locales: {
"/": {
lang: "en-US",
title: "",
description: "",
},
"/zh/": {
lang: "zh-CN",
title: "",
description: "",
},
},*/
plugins: [
{
name: 'release-vars',
extendsMarkdown: (md) => {
md.use(releaseVarsPlugin);
},
extendsPage: (page) => {
const lookup = page.filePathRelative ? '/' + page.filePathRelative : page.path;
const release = getReleaseFromPath(lookup);
if (!release) return;
const walk = (obj: Record<string, unknown> | undefined) => {
if (!obj) return;
for (const key of Object.keys(obj)) {
const v = obj[key];
if (typeof v === 'string') {
obj[key] = replaceReleaseTokens(v, release);
}
}
};
walk(page.frontmatter as Record<string, unknown>);
walk(page.routeMeta as Record<string, unknown>);
walk(page.data as unknown as Record<string, unknown>);
if (typeof page.title === 'string') {
page.title = replaceReleaseTokens(page.title, release);
}
},
},
],
// Enable it with pwa
shouldPrefetch: false,
theme
});