From 1ecc8089dd1f90ee20064cfda39855fc8805e9cf Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 26 Jan 2022 12:21:58 +0100 Subject: fix: replace dynamic import with require The table of contents was not able to get the headings list on first render because of dynamic import. By using require, it works as expected. --- src/pages/projet/[slug].tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pages/projet/[slug].tsx b/src/pages/projet/[slug].tsx index 0f3aea9..a9b5115 100644 --- a/src/pages/projet/[slug].tsx +++ b/src/pages/projet/[slug].tsx @@ -15,11 +15,12 @@ import { getAllProjectsFilename, getProjectData, } from '@utils/helpers/projects'; +import { MDXComponents } from 'mdx/types'; import { GetStaticPaths, GetStaticProps, GetStaticPropsContext } from 'next'; -import dynamic from 'next/dynamic'; import Head from 'next/head'; import { useRouter } from 'next/router'; import { ParsedUrlQuery } from 'querystring'; +import { ComponentType } from 'react'; import { Article, Graph, WebPage } from 'schema-dts'; const Project: NextPageWithLayout = ({ @@ -35,9 +36,8 @@ const Project: NextPageWithLayout = ({ update: meta.updatedOn, }; - const ProjectContent = dynamic( - () => import(`../../content/projects/${id}.mdx`) - ); + const ProjectContent: ComponentType = + require(`../../content/projects/${id}.mdx`).default; const webpageSchema: WebPage = { '@id': `${projectUrl}`, -- cgit v1.2.3