mirror of
https://github.com/jimeh/commonflow.org.git
synced 2026-02-19 05:46:40 +00:00
wip: toc clause numbers
This commit is contained in:
@@ -13,6 +13,7 @@ export interface TocItem {
|
||||
id: string;
|
||||
title: string;
|
||||
level: number;
|
||||
clause?: string;
|
||||
}
|
||||
|
||||
export interface FAQItem {
|
||||
@@ -25,6 +26,7 @@ export interface SpecSection {
|
||||
id: string;
|
||||
title: string;
|
||||
content: string;
|
||||
clause: string;
|
||||
}
|
||||
|
||||
export interface ParsedSpec {
|
||||
@@ -182,11 +184,13 @@ function findSpecSections(nodes: RootContent[]): SpecSection[] {
|
||||
for (const node of nodes) {
|
||||
if (node.type === "list" && (node as List).ordered) {
|
||||
const titles = extractListItemTitles(node as List);
|
||||
for (const title of titles) {
|
||||
for (let i = 0; i < titles.length; i++) {
|
||||
const title = titles[i];
|
||||
sections.push({
|
||||
id: `spec-${slugify(title)}`,
|
||||
title,
|
||||
content: "",
|
||||
clause: `${i + 1}.`,
|
||||
});
|
||||
}
|
||||
break; // Only process first ordered list
|
||||
@@ -286,7 +290,12 @@ function buildTocItems(parsed: Partial<ParsedSpec>): TocItem[] {
|
||||
|
||||
if (parsed.specSections) {
|
||||
for (const section of parsed.specSections) {
|
||||
items.push({ id: section.id, title: section.title, level: 3 });
|
||||
items.push({
|
||||
id: section.id,
|
||||
title: section.title,
|
||||
level: 3,
|
||||
clause: section.clause,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user