File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,13 @@ import Footer from "@/components/footer";
66import { canela_regu } from "@/lib/fonts" ;
77import { formatDate } from "../utils" ;
88
9+ // Remove a leading H1 and an immediate horizontal rule (---) from MDX content
10+ function stripTopHeadingAndHr ( mdx : string ) {
11+ return mdx
12+ . replace ( / ^ \s * # [ ^ \n ] * \n (?: \s * \n ) * / m, "" ) // strip leading H1 and following blank lines
13+ . replace ( / ^ \s * - - - \s * \n (?: \s * \n ) * / m, "" ) ; // strip immediate hr and following blank lines if present
14+ }
15+
916export async function generateStaticParams ( ) {
1017 let posts = getStoriesPosts ( ) ;
1118
@@ -63,6 +70,8 @@ export default function StoriesPost({ params }) {
6370 notFound ( ) ;
6471 }
6572
73+ const sanitizedContent = stripTopHeadingAndHr ( post . content ) ;
74+
6675 return (
6776 < div className = "min-h-screen bg-gradient-to-b" >
6877 < Header />
@@ -92,7 +101,7 @@ export default function StoriesPost({ params }) {
92101 ) }
93102
94103 < div className = "prose prose-lg max-w-none" >
95- < CustomMDX source = { post . content } />
104+ < CustomMDX source = { sanitizedContent } />
96105 </ div >
97106 </ article >
98107 </ div >
You can’t perform that action at this time.
0 commit comments