aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/cv.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-12-18 11:56:59 +0100
committerArmand Philippot <git@armandphilippot.com>2023-12-18 11:56:59 +0100
commitd592085dc0fec023dd9f3437d4c756d402ed8c8f (patch)
tree9bba6873cefac197934ca41eed22b0b7054e3f60 /src/pages/cv.tsx
parent67581629ea87162e6d47b39b867b37a9a50754aa (diff)
fix(pages): use dynamic imports for the table of contents
The ToCWidget relies on Javascript to display the headings. If JS is disabled in the browser, the widget is empty. For a better UX, we should use dynamic imports. Now, the ToC is only displayed when JS is enabled.
Diffstat (limited to 'src/pages/cv.tsx')
-rw-r--r--src/pages/cv.tsx11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/pages/cv.tsx b/src/pages/cv.tsx
index 92c3e9e..f0e1e8b 100644
--- a/src/pages/cv.tsx
+++ b/src/pages/cv.tsx
@@ -1,4 +1,5 @@
import type { GetStaticProps } from 'next';
+import dynamic from 'next/dynamic';
import Head from 'next/head';
import NextImage from 'next/image';
import React, { type ReactNode } from 'react';
@@ -12,7 +13,6 @@ import {
Page,
PageHeader,
PageSidebar,
- TocWidget,
PageBody,
} from '../components';
import { mdxComponents } from '../components/mdx';
@@ -24,6 +24,13 @@ import { getAboutPageGraph, getSchemaFrom } from '../utils/helpers';
import { loadTranslation } from '../utils/helpers/server';
import { useBreadcrumbs, useHeadingsTree } from '../utils/hooks';
+const Toc = dynamic(
+ async () => import('../components').then((mod) => mod.TocWidget),
+ {
+ ssr: false,
+ }
+);
+
const DownloadLink = (chunks: ReactNode) => (
<Link href={data.file} isDownload>
{chunks}
@@ -133,7 +140,7 @@ const CVPage: NextPageWithLayout = () => {
}}
/>
<PageSidebar>
- <TocWidget
+ <Toc
heading={<Heading level={3}>{messages.toc.title}</Heading>}
tree={tree}
/>