-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-config.js
60 lines (54 loc) · 1.38 KB
/
generate-config.js
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
// 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",
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