Skip to content

Commit

Permalink
Render top-level self-doc as just the first doc in the tree, not a se…
Browse files Browse the repository at this point in the history
…ction heading
  • Loading branch information
irskep committed Sep 6, 2024
1 parent 5e966d7 commit 4103644
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/engine/populateDocTreeDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ function renderSection(

const isOpen = activeDoc.refPath.startsWith(section.refPath);

if (level > 1 || section.selfDocHasContent) {
const docChildren = new Array<ListItem>();

if (level > 1) {
result.push({
tag: "heading",
level,
Expand All @@ -115,17 +117,24 @@ function renderSection(
? [getDocLink(section.selfDoc)]
: section.title,
});
} else if (section.selfDoc && section.selfDocHasContent) {
docChildren.push({
tag: "list_item",
children: [{ tag: "para", children: [getDocLink(section.selfDoc)] }],
});
}

const docChildren: ListItem[] = section.docs.map((doc) => ({
tag: "list_item",
children: [
{
tag: "para",
children: [getDocLink(doc)],
},
],
}));
for (const doc of section.docs) {
docChildren.push({
tag: "list_item",
children: [
{
tag: "para",
children: [getDocLink(doc)],
},
],
});
}
const sectionChildren: ListItem[] = section.children.map((child, i) => ({
tag: "list_item",
children: renderSection(
Expand Down

0 comments on commit 4103644

Please sign in to comment.