mirror of
https://git.hmsn.ink/kospo/svcm/dmz.git
synced 2026-03-20 05:33:33 +09:00
first
This commit is contained in:
19
server/generate/scan.ts
Normal file
19
server/generate/scan.ts
Normal 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$/, '')
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user