diff --git a/scripts/page.ts b/scripts/page.ts index 4e29ee8a..8f5a1a61 100644 --- a/scripts/page.ts +++ b/scripts/page.ts @@ -56,7 +56,7 @@ function isSectionItem(item: SectionItem | Section): item is SectionItem { function enrichTableOfContents(sections: Section[]): EnrichedSection[] { return sections.map((section) => { return { - id: section.title.toLowerCase().replace(" ", "_"), + id: section.title.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/(^_|_$)/g, ""), title: section.title, items: section.items.map((item) => { if (isSectionItem(item)) { @@ -101,11 +101,7 @@ function renderSection(section: EnrichedSection | EnrichedSectionItem): string { } else { return `