@@ -7,9 +7,11 @@ import {
77} from 'fumadocs-ui/page' ;
88import { notFound } from 'next/navigation' ;
99import { createRelativeLink } from 'fumadocs-ui/mdx' ;
10+ import defaultMdxComponents from 'fumadocs-ui/mdx' ;
1011import { getMDXComponents } from '@/mdx-components' ;
1112import type { Metadata } from 'next' ;
1213import { buildSeoProfile } from '@/lib/seo' ;
14+ import { getDisplayTitle , getDisplayTitleNode } from '@/lib/title' ;
1315
1416const siteUrl = ( process . env . NEXT_PUBLIC_SITE_URL ?? 'https://ml.kanaries.net' ) . replace ( / \/ $ / , '' ) ;
1517
@@ -24,6 +26,17 @@ export default async function Page(props: {
2426 const slug = params . slug ?? [ ] ;
2527 const path = slug . length ? `/docs/${ slug . join ( '/' ) } ` : '/docs' ;
2628 const canonicalUrl = new URL ( path , siteUrl ) . toString ( ) ;
29+ const displayTitle = getDisplayTitle ( page . data . title ) ;
30+ const displayToc = page . data . toc
31+ . map ( ( item ) => {
32+ const title = getDisplayTitleNode ( item . title ) ;
33+
34+ return {
35+ ...item ,
36+ title,
37+ } ;
38+ } )
39+ . filter ( ( item ) => item . title !== displayTitle ) ;
2740 const seoProfile = buildSeoProfile ( {
2841 title : page . data . title ,
2942 description : page . data . description ,
@@ -66,14 +79,24 @@ export default async function Page(props: {
6679 < >
6780 < script type = "application/ld+json" dangerouslySetInnerHTML = { { __html : JSON . stringify ( articleLd ) } } />
6881 < script type = "application/ld+json" dangerouslySetInnerHTML = { { __html : JSON . stringify ( faqLd ) } } />
69- < DocsPage toc = { page . data . toc } full = { page . data . full } >
70- < DocsTitle > { page . data . title } </ DocsTitle >
82+ < DocsPage toc = { displayToc } full = { page . data . full } >
83+ < DocsTitle > { displayTitle } </ DocsTitle >
7184 < DocsDescription > { page . data . description } </ DocsDescription >
7285 < DocsBody >
7386 < MDXContent
7487 components = { getMDXComponents ( {
7588 // this allows you to link to other pages with relative file paths
7689 a : createRelativeLink ( source , page ) ,
90+ h1 : ( props ) => {
91+ const children = getDisplayTitleNode ( props . children ) ;
92+
93+ if ( children === displayTitle ) return null ;
94+
95+ return defaultMdxComponents . h1 ( {
96+ ...props ,
97+ children,
98+ } ) ;
99+ } ,
77100 } ) }
78101 />
79102 < section className = "mt-12 rounded-lg border border-fd-border bg-fd-muted/40 p-6" >
0 commit comments