website: Fix template index.json generate error

This commit is contained in:
weishu
2023-10-21 10:28:23 +08:00
parent 433627c82b
commit 3ebee74efc
2 changed files with 9 additions and 6 deletions

View File

@@ -7,9 +7,14 @@ export default defineConfig( {
title: 'KernelSU', title: 'KernelSU',
locales: locales.locales, locales: locales.locales,
buildEnd: async (config: SiteConfig) => { buildEnd: async (config: SiteConfig) => {
const templateDir = resolve(config.outDir, 'templates') const templateDir = resolve(config.outDir, 'templates');
const files = await readdir(templateDir); const templateList = resolve(templateDir, "index.json");
const templateList = resolve(templateDir, "index.json") let files = [];
await writeFile(templateList, JSON.stringify(files)) try {
files = await readdir(templateDir);
} catch(e) {
// ignore
}
await writeFile(templateList, JSON.stringify(files));
} }
}) })

View File

@@ -1,2 +0,0 @@
# we generate index.json at build time
index.json