Home / Function/ annotateContentExport() — astro Function Reference

annotateContentExport() — astro Function Reference

Architecture documentation for the annotateContentExport() function in vite-plugin-mdx-postprocess.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  208f74e4_5dbd_d2b1_4880_e0fe1c61ec8d["annotateContentExport()"]
  1d16286a_a608_ecf0_1939_33200eaee4a0["vite-plugin-mdx-postprocess.ts"]
  208f74e4_5dbd_d2b1_4880_e0fe1c61ec8d -->|defined in| 1d16286a_a608_ecf0_1939_33200eaee4a0
  41ea6fc9_a90c_0a26_da48_58217361f433["vitePluginMdxPostprocess()"]
  41ea6fc9_a90c_0a26_da48_58217361f433 -->|calls| 208f74e4_5dbd_d2b1_4880_e0fe1c61ec8d
  21a3b591_b826_af88_df86_c38ee83330f7["isSpecifierImported()"]
  208f74e4_5dbd_d2b1_4880_e0fe1c61ec8d -->|calls| 21a3b591_b826_af88_df86_c38ee83330f7
  style 208f74e4_5dbd_d2b1_4880_e0fe1c61ec8d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/mdx/src/vite-plugin-mdx-postprocess.ts lines 108–137

function annotateContentExport(
	code: string,
	id: string,
	ssr: boolean,
	imports: readonly ImportSpecifier[],
) {
	// Mark `Content` as MDX component
	code += `\nContent[Symbol.for('mdx-component')] = true`;
	// Ensure styles and scripts are injected into a `<head>` when a layout is not applied
	code += `\nContent[Symbol.for('astro.needsHeadRendering')] = !Boolean(frontmatter.layout);`;
	// Assign the `moduleId` metadata to `Content`
	code += `\nContent.moduleId = ${JSON.stringify(id)};`;

	// Tag the `Content` export as "astro:jsx" so it's quicker to identify how to render this component
	if (ssr) {
		if (
			!isSpecifierImported(
				code,
				imports,
				astroTagComponentImportRegex,
				'astro/runtime/server/index.js',
			)
		) {
			code += `\nimport { __astro_tag_component__ } from 'astro/runtime/server/index.js';`;
		}
		code += `\n__astro_tag_component__(Content, 'astro:jsx');`;
	}

	return code;
}

Domain

Subdomains

Frequently Asked Questions

What does annotateContentExport() do?
annotateContentExport() is a function in the astro codebase, defined in packages/integrations/mdx/src/vite-plugin-mdx-postprocess.ts.
Where is annotateContentExport() defined?
annotateContentExport() is defined in packages/integrations/mdx/src/vite-plugin-mdx-postprocess.ts at line 108.
What does annotateContentExport() call?
annotateContentExport() calls 1 function(s): isSpecifierImported.
What calls annotateContentExport()?
annotateContentExport() is called by 1 function(s): vitePluginMdxPostprocess.

Analyze Your Own Codebase

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

Try Supermodel Free