mirror of
https://git.hmsn.ink/kospo/svcm/oa.git
synced 2026-03-20 05:53:27 +09:00
20 lines
569 B
TypeScript
20 lines
569 B
TypeScript
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$/, '')
|
|
})
|
|
}
|