mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-07 05:40:20 +03:00
Extract logic
This commit is contained in:
parent
84f8b2fcbd
commit
9d9f5cc8ba
|
@ -50,22 +50,26 @@ export const getStaticPaths: GetStaticPaths<ParsedUrlQuery> = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
const getPathFull = (slug: ReadonlyArray<string>): ReadonlyArray<string> => slug
|
||||
|
||||
export const getStaticProps: GetStaticProps<PropsPage, ParsedUrlQuery> = async (args) => {
|
||||
if (!args.params) {
|
||||
return { notFound: true }
|
||||
}
|
||||
|
||||
const pathFull = getPathFull(args.params.slug)
|
||||
|
||||
const mdx = await serialize(fs.readFileSync(`${path.join('docs', ...pathFull)}.mdx`, 'utf-8'), {
|
||||
parseFrontmatter: true,
|
||||
mdxOptions: {
|
||||
remarkPlugins,
|
||||
},
|
||||
})
|
||||
|
||||
return {
|
||||
props: {
|
||||
slug: args.params.slug,
|
||||
mdx: await serialize(
|
||||
fs.readFileSync(`${path.join('docs', ...args.params.slug)}.mdx`, 'utf-8'),
|
||||
{
|
||||
parseFrontmatter: true,
|
||||
mdxOptions: {
|
||||
remarkPlugins,
|
||||
},
|
||||
}
|
||||
),
|
||||
mdx,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user