mirror of
https://github.com/explosion/spaCy.git
synced 2025-06-29 17:33:10 +03:00
Allow to handle directories for page creation
This commit is contained in:
parent
4151870c9f
commit
d625737451
|
@ -28,12 +28,21 @@ export const getStaticPaths: GetStaticPaths<ParsedUrlQuery> = async () => {
|
||||||
// This function needs to be defined inside `getStaticPath` to be executed in executed in the correct context
|
// This function needs to be defined inside `getStaticPath` to be executed in executed in the correct context
|
||||||
const loadFolder = (): Array<{ params: ParsedUrlQuery }> =>
|
const loadFolder = (): Array<{ params: ParsedUrlQuery }> =>
|
||||||
fs
|
fs
|
||||||
.readdirSync(path.join('docs'))
|
.readdirSync(path.join('docs'), { withFileTypes: true })
|
||||||
.map((filename) => ({
|
.flatMap((dirent: fs.Dirent) => {
|
||||||
|
if (dirent.isDirectory()) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
if (!dirent.name.includes('.mdx')) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
params: {
|
params: {
|
||||||
slug: filename.replace('.mdx', ''),
|
slug: dirent.name.replace('.mdx', ''),
|
||||||
},
|
},
|
||||||
}))
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
paths: loadFolder(),
|
paths: loadFolder(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user