123
This commit is contained in:
@@ -98,11 +98,16 @@ export const getDocBySlug = cache(async (slug: string[]): Promise<DocPage | null
|
||||
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
||||
const { data, content } = matter(fileContent);
|
||||
|
||||
// Strip the first H1 heading from the markdown body since the page component
|
||||
// renders the title separately from meta.title. gray-matter may leave leading
|
||||
// newlines in content, so we trim the left first before matching.
|
||||
const contentWithoutH1 = content.replace(/^\s*#[^\n]*\n+/, '');
|
||||
|
||||
// Process markdown
|
||||
const processedContent = await remark()
|
||||
.use(remarkGfm)
|
||||
.use(html, { sanitize: false })
|
||||
.process(content);
|
||||
.process(contentWithoutH1);
|
||||
|
||||
let contentHtml = processedContent.toString();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user