diff --git a/website/pages/[...slug].tsx b/website/pages/[...slug].tsx index b8b40d9db..eab8e2a71 100644 --- a/website/pages/[...slug].tsx +++ b/website/pages/[...slug].tsx @@ -50,22 +50,26 @@ export const getStaticPaths: GetStaticPaths = async () => { } } +const getPathFull = (slug: ReadonlyArray): ReadonlyArray => slug + export const getStaticProps: GetStaticProps = 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, }, } }