Skip to content

Commit 21e0ea7

Browse files
committed
fix(metadata): ensure YAML frontmatter is captured when preceding first heading
1 parent 7e3f5d2 commit 21e0ea7

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/generators/metadata/utils/parse.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ export const parseApiDoc = ({ path, tree }, typeMap) => {
102102
? tree.children.length
103103
: tree.children.indexOf(nextHeadingNode);
104104

105-
// Create subtree for this section
106-
const subTree = createTree('root', tree.children.slice(index, stop));
105+
// Create subtree for this section. If it's the first entry, we start from the
106+
// beginning of the tree to ensure top-level nodes (like YAML) are captured.
107+
const startIndex = metadataCollection.length === 0 ? 0 : index;
108+
const subTree = createTree('root', tree.children.slice(startIndex, stop));
107109

108110
visit(subTree, UNIST.isStabilityNode, node =>
109111
visitStability(node, ignoreStability ? undefined : metadata)

0 commit comments

Comments
 (0)