This commit is contained in:
2026-02-28 23:35:34 +08:00
parent 3956ee4806
commit 562c316c54
5 changed files with 129 additions and 16 deletions

View File

@@ -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();