-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-config.js
More file actions
72 lines (66 loc) · 1.65 KB
/
generate-config.js
File metadata and controls
72 lines (66 loc) · 1.65 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
65
66
67
68
69
70
71
72
// generate-config.js
const fs = require("fs");
const path = require("path");
let md_dir = "pages";
const files = fs
.readdirSync(md_dir)
.filter((file) => file.endsWith(".md"));
// .filter((file) => file.startsWith("HelloGithub") && file.endsWith(".md"));
let config = `
import { defineConfig } from 'vitepress'
export default defineConfig({
title: "My Awesome Project",
description: "A VitePress Site",
vite: {
server: {
host: '0.0.0.0', // 监听所有网络接口
port: 3000, // 指定端口
strictPort: true, // 如果端口被占用则退出
allowedHosts: [
'arch.hjkl01.cn',
'localhost',
'127.0.0.1'
]
}
},
themeConfig: {
nav: [
{ text: 'HelloGithub', link: '/HelloGitHub100.html' },
{ text: 'Home', link: '/HelloGitHub100' },
// { text: 'Examples', link: '/markdown-examples' },
],
sidebar: [
{
text: 'HelloGithub',
items: [
`;
files.forEach((file) => {
let temp = ` { text: '${file.replace("HelloGitHub", "").replace(".md", "")}', link: '/${file.replace(".md", "")}' },\n`;
// console.log(temp);
config += temp;
});
config += `
]
},
{
text: 'Examples',
items: [
{ text: 'Markdown Examples', link: '/markdown-examples' },
{ text: 'Runtime API Examples', link: '/api-examples' }
]
}
],
socialLinks: [
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
],
search: {
provider: 'local'
}
}
})
`;
fs.writeFileSync(
path.join(__dirname, md_dir + "/.vitepress/" + "config.mts"),
config,
);
// pages/.vitepress/config.mts