返回 slidev
gen-layouts.ts
根目录 / scripts / gen-layouts.ts
1 import fs from 'node:fs/promises'
2 import { fileURLToPath } from 'node:url'
3 import fg from 'fast-glob'
4
5 const files = await fg('*.vue', {
6 cwd: fileURLToPath(new URL('../packages/client/layouts', import.meta.url)),
7 })
8
9 await fs.writeFile(new URL('../packages/types/src/builtin-layouts.ts', import.meta.url), `
10 export type BuiltinLayouts =
11 ${files.sort().map(i => ` | '${i.replace('.vue', '')}'`).join('\n')}
12 `, 'utf-8')
13
13 lines TYPESCRIPT