Home / Function/ addServerDeferMetadata() — astro Function Reference

addServerDeferMetadata() — astro Function Reference

Architecture documentation for the addServerDeferMetadata() function in rehype.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  604614d7_2c85_5d45_05c7_7a02b9064597["addServerDeferMetadata()"]
  89da4403_ab4a_62fa_64f0_d53bd0b3aee8["rehype.ts"]
  604614d7_2c85_5d45_05c7_7a02b9064597 -->|defined in| 89da4403_ab4a_62fa_64f0_d53bd0b3aee8
  d17ed63a_5ec6_bc29_96d7_b3145cec7d5d["rehypeAnalyzeAstroMetadata()"]
  d17ed63a_5ec6_bc29_96d7_b3145cec7d5d -->|calls| 604614d7_2c85_5d45_05c7_7a02b9064597
  style 604614d7_2c85_5d45_05c7_7a02b9064597 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/jsx/rehype.ts lines 342–375

function addServerDeferMetadata(
	node: MdxJsxFlowElementHast | MdxJsxTextElementHast,
	meta: { path: string; name: string },
	resolvedPath: string,
) {
	const attributeNames = node.attributes
		.map((attr) => (attr.type === 'mdxJsxAttribute' ? attr.name : null))
		.filter(Boolean);

	if (!attributeNames.includes('server:component-directive')) {
		node.attributes.push({
			type: 'mdxJsxAttribute',
			name: 'server:component-directive',
			value: 'server:defer',
		});
	}
	if (!attributeNames.includes('server:component-path')) {
		node.attributes.push({
			type: 'mdxJsxAttribute',
			name: 'server:component-path',
			value: resolvedPath,
		});
	}
	if (!attributeNames.includes('server:component-export')) {
		if (meta.name === '*') {
			meta.name = node.name!.split('.').slice(1).join('.')!;
		}
		node.attributes.push({
			type: 'mdxJsxAttribute',
			name: 'server:component-export',
			value: meta.name,
		});
	}
}

Domain

Subdomains

Frequently Asked Questions

What does addServerDeferMetadata() do?
addServerDeferMetadata() is a function in the astro codebase, defined in packages/astro/src/jsx/rehype.ts.
Where is addServerDeferMetadata() defined?
addServerDeferMetadata() is defined in packages/astro/src/jsx/rehype.ts at line 342.
What calls addServerDeferMetadata()?
addServerDeferMetadata() is called by 1 function(s): rehypeAnalyzeAstroMetadata.

Analyze Your Own Codebase

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

Try Supermodel Free