Home / Function/ collectHeadings() — astro Function Reference

collectHeadings() — astro Function Reference

Architecture documentation for the collectHeadings() function in runtime.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  4e652fe4_0ba8_1916_bc44_653f51aece72["collectHeadings()"]
  df14bb08_8e2c_26c3_53bb_884062fbbac0["runtime.ts"]
  4e652fe4_0ba8_1916_bc44_653f51aece72 -->|defined in| df14bb08_8e2c_26c3_53bb_884062fbbac0
  01ba618d_a7bb_157f_c696_1b6d9dc801bd["createGetHeadings()"]
  01ba618d_a7bb_157f_c696_1b6d9dc801bd -->|calls| 4e652fe4_0ba8_1916_bc44_653f51aece72
  05e8aed1_6bae_a4c9_a469_dc18b916dcc9["getTextContent()"]
  4e652fe4_0ba8_1916_bc44_653f51aece72 -->|calls| 05e8aed1_6bae_a4c9_a469_dc18b916dcc9
  style 4e652fe4_0ba8_1916_bc44_653f51aece72 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/markdoc/src/runtime.ts lines 172–199

export function collectHeadings(
	children: RenderableTreeNode[],
	collectedHeadings: MarkdownHeading[],
) {
	for (const node of children) {
		if (typeof node !== 'object' || !Markdoc.Tag.isTag(node)) continue;

		if (node.attributes.__collectHeading === true && typeof node.attributes.level === 'number') {
			collectedHeadings.push({
				slug: node.attributes.id,
				depth: node.attributes.level,
				text: getTextContent(node.children),
			});
			continue;
		}

		for (const level of headingLevels) {
			if (node.name === 'h' + level) {
				collectedHeadings.push({
					slug: node.attributes.id,
					depth: level,
					text: getTextContent(node.children),
				});
			}
		}
		collectHeadings(node.children, collectedHeadings);
	}
}

Domain

Subdomains

Frequently Asked Questions

What does collectHeadings() do?
collectHeadings() is a function in the astro codebase, defined in packages/integrations/markdoc/src/runtime.ts.
Where is collectHeadings() defined?
collectHeadings() is defined in packages/integrations/markdoc/src/runtime.ts at line 172.
What does collectHeadings() call?
collectHeadings() calls 1 function(s): getTextContent.
What calls collectHeadings()?
collectHeadings() is called by 1 function(s): createGetHeadings.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free