Home / Function/ getMdxFrontmatterVariablePath() — astro Function Reference

getMdxFrontmatterVariablePath() — astro Function Reference

Architecture documentation for the getMdxFrontmatterVariablePath() function in rehype-collect-headings.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  b3ba1b83_8d71_6d57_91fc_523c654993db["getMdxFrontmatterVariablePath()"]
  cabcee29_0c1e_3e48_86ec_bfe2c4e47f2c["rehype-collect-headings.ts"]
  b3ba1b83_8d71_6d57_91fc_523c654993db -->|defined in| cabcee29_0c1e_3e48_86ec_bfe2c4e47f2c
  634cb6a1_87c1_3f69_eebe_1e03253219c2["rehypeHeadingIds()"]
  634cb6a1_87c1_3f69_eebe_1e03253219c2 -->|calls| b3ba1b83_8d71_6d57_91fc_523c654993db
  style b3ba1b83_8d71_6d57_91fc_523c654993db fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/markdown/remark/src/rehype-collect-headings.ts lines 84–114

function getMdxFrontmatterVariablePath(node: MdxTextExpression): string[] | Error {
	if (!node.data?.estree || node.data.estree.body.length !== 1) return new Error();

	const statement = node.data.estree.body[0];

	// Check for "[ANYTHING].[ANYTHING]".
	if (statement?.type !== 'ExpressionStatement' || statement.expression.type !== 'MemberExpression')
		return new Error();

	let expression: Expression | Super = statement.expression;
	const expressionPath: string[] = [];

	// Traverse the expression, collecting the variable path.
	while (
		expression.type === 'MemberExpression' &&
		expression.property.type === (expression.computed ? 'Literal' : 'Identifier')
	) {
		expressionPath.push(
			expression.property.type === 'Literal'
				? String(expression.property.value)
				: expression.property.name,
		);

		expression = expression.object;
	}

	// Check for "frontmatter.[ANYTHING]".
	if (expression.type !== 'Identifier' || expression.name !== 'frontmatter') return new Error();

	return expressionPath.reverse();
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does getMdxFrontmatterVariablePath() do?
getMdxFrontmatterVariablePath() is a function in the astro codebase, defined in packages/markdown/remark/src/rehype-collect-headings.ts.
Where is getMdxFrontmatterVariablePath() defined?
getMdxFrontmatterVariablePath() is defined in packages/markdown/remark/src/rehype-collect-headings.ts at line 84.
What calls getMdxFrontmatterVariablePath()?
getMdxFrontmatterVariablePath() is called by 1 function(s): rehypeHeadingIds.

Analyze Your Own Codebase

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

Try Supermodel Free