Skip to content

Commit 39bb036

Browse files
committed
perf: config json
1 parent 1378773 commit 39bb036

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ docs/.vitepress/dist
2222
docs/.vitepress/cache
2323

2424
/docs/api
25+
/docs/_config.json
2526

2627
vite.config.ts.timestamp-*

docs/.vitepress/plugins/mirror.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ async function* traverseDirectory(
102102

103103
export const buildEnd = async () => {
104104
if (!useMirror) return;
105-
const baseDir = posixPath(process.cwd() + '/.vitepress/dist');
105+
const distDir = posixPath(process.cwd() + '/.vitepress/dist');
106106
const relativePath = (v: string) => {
107-
return v.substring(baseDir.length);
107+
return v.substring(distDir.length);
108108
};
109109
const htmlUrlMap: Record<string, string> = {};
110-
for await (const filePathName of traverseDirectory(baseDir)) {
110+
for await (const filePathName of traverseDirectory(distDir)) {
111111
if (filePathName.endsWith('.html')) {
112112
const textFileName = filePathName.replace(/\.html$/, '_.md');
113113
await fs.copyFile(filePathName, textFileName);
@@ -121,16 +121,16 @@ export const buildEnd = async () => {
121121
htmlUrlMap[k.replace(/\.html$/, '')] = htmlUrlMap[k];
122122
}
123123
});
124-
await fs.writeFile(
125-
baseDir + '/_config.json',
126-
JSON.stringify(
127-
{
128-
htmlUrlMap,
129-
},
130-
undefined,
131-
2,
132-
),
124+
const configFileRelativePath = '/_config.json';
125+
const configText = JSON.stringify(
126+
{
127+
htmlUrlMap,
128+
},
129+
undefined,
130+
2,
133131
);
132+
await fs.writeFile(distDir + configFileRelativePath, configText);
133+
await fs.writeFile(process.cwd() + configFileRelativePath, configText);
134134
};
135135

136136
const Parser =

0 commit comments

Comments
 (0)