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