fix: handle empty heading text in TOC generation

pull/18314/head
GuanMu 1 year ago
parent e9cb9e8695
commit b9af8effab

@ -38,7 +38,7 @@ const useToc = (apiBaseUrl: string, locale: string) => {
const tocItems: TocItem[] = headingElementsArray.map((heading, index) => ({ const tocItems: TocItem[] = headingElementsArray.map((heading, index) => ({
href: `#section-${index}`, href: `#section-${index}`,
text: (heading.textContent || `章节 ${index + 1}`).trim(), text: (heading.textContent || '').trim(),
index, index,
})) }))

Loading…
Cancel
Save