Home / Function/ simplifyPlainMdxComponentNode() — astro Function Reference

simplifyPlainMdxComponentNode() — astro Function Reference

Architecture documentation for the simplifyPlainMdxComponentNode() function in rehype-optimize-static.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  5c90d957_b7b9_18dc_7085_ecc7ecd641ba["simplifyPlainMdxComponentNode()"]
  36422914_2d7c_adeb_c777_76a007e3cb87["rehype-optimize-static.ts"]
  5c90d957_b7b9_18dc_7085_ecc7ecd641ba -->|defined in| 36422914_2d7c_adeb_c777_76a007e3cb87
  d6e3dc2a_c11c_d2d3_2b99_f6aee60fd384["rehypeOptimizeStatic()"]
  d6e3dc2a_c11c_d2d3_2b99_f6aee60fd384 -->|calls| 5c90d957_b7b9_18dc_7085_ecc7ecd641ba
  893ecef5_14a8_82b0_1724_42530072391e["isMdxComponentNode()"]
  5c90d957_b7b9_18dc_7085_ecc7ecd641ba -->|calls| 893ecef5_14a8_82b0_1724_42530072391e
  style 5c90d957_b7b9_18dc_7085_ecc7ecd641ba fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/mdx/src/rehype-optimize-static.ts lines 276–300

function simplifyPlainMdxComponentNode(node: Node, ignoreElementNames: Set<string>) {
	if (
		!isMdxComponentNode(node) ||
		// Attributes could be dynamic, so bail if so.
		node.attributes.length > 0 ||
		// Fragments are also dynamic
		!node.name ||
		// Ignore if the node name is in the ignore list
		ignoreElementNames.has(node.name) ||
		// If the node name has uppercase characters, it's likely an actual MDX component
		node.name.toLowerCase() !== node.name
	) {
		return;
	}

	// Mutate as hast element node
	const newNode = node as unknown as Element;
	newNode.type = 'element';
	newNode.tagName = node.name;
	newNode.properties = {};

	// @ts-expect-error Delete mdx-specific properties
	node.attributes = undefined;
	node.data = undefined;
}

Domain

Subdomains

Frequently Asked Questions

What does simplifyPlainMdxComponentNode() do?
simplifyPlainMdxComponentNode() is a function in the astro codebase, defined in packages/integrations/mdx/src/rehype-optimize-static.ts.
Where is simplifyPlainMdxComponentNode() defined?
simplifyPlainMdxComponentNode() is defined in packages/integrations/mdx/src/rehype-optimize-static.ts at line 276.
What does simplifyPlainMdxComponentNode() call?
simplifyPlainMdxComponentNode() calls 1 function(s): isMdxComponentNode.
What calls simplifyPlainMdxComponentNode()?
simplifyPlainMdxComponentNode() is called by 1 function(s): rehypeOptimizeStatic.

Analyze Your Own Codebase

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

Try Supermodel Free