Skip to content
This repository was archived by the owner on Apr 10, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions apps/nextjs-app/lib/sections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ export type Section = H2Node['attributes'] & {
children: Array<Subsection>;
};

export function collectSections(nodes: Array<Node>, slugify = slugifyWithCounter()) {
let sections: Array<Section> = [];

export function collectSections(nodes: Array<Node>, slugify = slugifyWithCounter(), sections: Array<Section> = []) {
for (let node of nodes) {
if (isH2Node(node) || isH3Node(node)) {
let title = getNodeText(node);
Expand All @@ -84,7 +82,7 @@ export function collectSections(nodes: Array<Node>, slugify = slugifyWithCounter
}
}

sections.push(...collectSections(node.children ?? [], slugify));
collectSections(node.children ?? [], slugify, sections);
}

return sections;
Expand Down
Loading