mirror of
https://github.com/m1ngsama/documents.git
synced 2025-12-24 10:51:23 +00:00
16 lines
396 B
TypeScript
16 lines
396 B
TypeScript
import { readdirSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
|
|
export function scanDir(dirname: string) {
|
|
const dirpath = path.resolve(__dirname, `../${dirname}`)
|
|
const res = readdirSync(dirpath)
|
|
|
|
const markdownFileNames = res.filter(name => name.endsWith('.md'))
|
|
|
|
return markdownFileNames.map((v) => {
|
|
return {
|
|
filename: v,
|
|
link: path.join(dirname, v),
|
|
}
|
|
})
|
|
}
|