This commit is contained in:
2025-05-24 01:47:40 +09:00
commit 09d97cbb0b
1594 changed files with 184634 additions and 0 deletions

19
server/generate/scan.ts Normal file
View File

@@ -0,0 +1,19 @@
import path from 'node:path'
import fg from 'fast-glob'
export async function scanRoutes(cwd: string) {
const files = await fg([path.resolve(cwd, 'src/pages/**/*.vue').replace(/\\/g, '/')])
return files
.filter(path => !path.includes('src/pages/[...all].vue')) // ignore root catch-all route
.map((file) => {
const name = file
.replace(/\.vue$/, '')
.replace(cwd.replace(/\\/g, '/'), '')
.replace(/\/+/g, '/')
.replace('/src/pages/', '')
.toLowerCase()
return '/' + name.replace(/index$/, '')
})
}