Home / Function/ addClientMetadata() — astro Function Reference

addClientMetadata() — astro Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

packages/astro/src/jsx/rehype.ts lines 263–296

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

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

Domain

Subdomains

Frequently Asked Questions

What does addClientMetadata() do?
addClientMetadata() is a function in the astro codebase, defined in packages/astro/src/jsx/rehype.ts.
Where is addClientMetadata() defined?
addClientMetadata() is defined in packages/astro/src/jsx/rehype.ts at line 263.
What calls addClientMetadata()?
addClientMetadata() 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