Home / Function/ getContentEntryType() — astro Function Reference

getContentEntryType() — astro Function Reference

Architecture documentation for the getContentEntryType() function in content-entry-type.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  8da81c7c_4056_9a1c_b1a1_0ac3cbab6581["getContentEntryType()"]
  b46411b3_6535_0116_92ac_cd60b744df11["content-entry-type.ts"]
  8da81c7c_4056_9a1c_b1a1_0ac3cbab6581 -->|defined in| b46411b3_6535_0116_92ac_cd60b744df11
  836f9b8a_c52a_62f8_d3fc_886fcebfc903["safeParseFrontmatter()"]
  8da81c7c_4056_9a1c_b1a1_0ac3cbab6581 -->|calls| 836f9b8a_c52a_62f8_d3fc_886fcebfc903
  609f9657_5b88_a72f_9d11_976071f35d46["raiseValidationErrors()"]
  8da81c7c_4056_9a1c_b1a1_0ac3cbab6581 -->|calls| 609f9657_5b88_a72f_9d11_976071f35d46
  5b158f1a_da81_b230_bb87_31167f3836a8["resolvePartials()"]
  8da81c7c_4056_9a1c_b1a1_0ac3cbab6581 -->|calls| 5b158f1a_da81_b230_bb87_31167f3836a8
  3dea6645_485e_c678_4a6c_00567db55d09["getUsedTags()"]
  8da81c7c_4056_9a1c_b1a1_0ac3cbab6581 -->|calls| 3dea6645_485e_c678_4a6c_00567db55d09
  c2c7a61c_9a8b_d227_0cd0_3736afcea46d["emitOptimizedImages()"]
  8da81c7c_4056_9a1c_b1a1_0ac3cbab6581 -->|calls| c2c7a61c_9a8b_d227_0cd0_3736afcea46d
  8445015d_9459_525c_ff94_499495ecda5a["getStringifiedImports()"]
  8da81c7c_4056_9a1c_b1a1_0ac3cbab6581 -->|calls| 8445015d_9459_525c_ff94_499495ecda5a
  e0e4cd3c_ee40_dc1a_eea2_14ca10d30f73["getStringifiedMap()"]
  8da81c7c_4056_9a1c_b1a1_0ac3cbab6581 -->|calls| e0e4cd3c_ee40_dc1a_eea2_14ca10d30f73
  style 8da81c7c_4056_9a1c_b1a1_0ac3cbab6581 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/markdoc/src/content-entry-type.ts lines 19–147

export async function getContentEntryType({
	markdocConfigResult,
	astroConfig,
	options,
}: {
	astroConfig: AstroConfig;
	markdocConfigResult?: MarkdocConfigResult;
	options?: MarkdocIntegrationOptions;
}): Promise<ContentEntryType> {
	return {
		extensions: ['.mdoc'],
		getEntryInfo({ fileUrl, contents }) {
			const parsed = safeParseFrontmatter(contents, fileURLToPath(fileUrl));
			return {
				data: parsed.frontmatter,
				body: parsed.content.trim(),
				slug: parsed.frontmatter.slug,
				rawData: parsed.rawFrontmatter,
			};
		},
		handlePropagation: true,
		async getRenderModule({ contents, fileUrl, viteId }) {
			const parsed = safeParseFrontmatter(contents, fileURLToPath(fileUrl));
			const tokenizer = getMarkdocTokenizer(options);
			let tokens = tokenizer.tokenize(parsed.content);

			if (options?.allowHTML) {
				tokens = htmlTokenTransform(tokenizer, tokens);
			}

			const ast = Markdoc.parse(tokens);
			const userMarkdocConfig = markdocConfigResult?.config ?? {};
			const markdocConfigUrl = markdocConfigResult?.fileUrl;
			const pluginContext = this;
			const markdocConfig = await setupConfig(userMarkdocConfig, options);
			const filePath = fileURLToPath(fileUrl);
			raiseValidationErrors({
				ast,
				/* Raised generics issue with Markdoc core https://github.com/markdoc/markdoc/discussions/400 */
				markdocConfig: markdocConfig as MarkdocConfig,
				viteId,
				astroConfig,
				filePath,
			});
			await resolvePartials({
				ast,
				markdocConfig: markdocConfig as MarkdocConfig,
				fileUrl,
				allowHTML: options?.allowHTML,
				tokenizer,
				pluginContext,
				root: astroConfig.root,
				raisePartialValidationErrors: (partialAst, partialPath) => {
					raiseValidationErrors({
						ast: partialAst,
						markdocConfig: markdocConfig as MarkdocConfig,
						viteId,
						astroConfig,
						filePath: partialPath,
					});
				},
			});

			const usedTags = getUsedTags(ast);

			let componentConfigByTagMap: Record<string, ComponentConfig> = {};
			// Only include component imports for tags used in the document.
			// Avoids style and script bleed.
			for (const tag of usedTags) {
				const render = markdocConfig.tags?.[tag]?.render;
				if (isComponentConfig(render)) {
					componentConfigByTagMap[tag] = render;
				}
			}
			let componentConfigByNodeMap: Record<string, ComponentConfig> = {};
			for (const [nodeType, schema] of Object.entries(markdocConfig.nodes ?? {})) {
				const render = schema?.render;
				if (isComponentConfig(render)) {
					componentConfigByNodeMap[nodeType] = render;
				}
			}

Domain

Subdomains

Frequently Asked Questions

What does getContentEntryType() do?
getContentEntryType() is a function in the astro codebase, defined in packages/integrations/markdoc/src/content-entry-type.ts.
Where is getContentEntryType() defined?
getContentEntryType() is defined in packages/integrations/markdoc/src/content-entry-type.ts at line 19.
What does getContentEntryType() call?
getContentEntryType() calls 7 function(s): emitOptimizedImages, getStringifiedImports, getStringifiedMap, getUsedTags, raiseValidationErrors, resolvePartials, safeParseFrontmatter.

Analyze Your Own Codebase

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

Try Supermodel Free