Home / Function/ getContentConfigFromGlobal() — astro Function Reference

getContentConfigFromGlobal() — astro Function Reference

Architecture documentation for the getContentConfigFromGlobal() function in vite-plugin-content-imports.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  0899dca1_e80f_b4eb_f265_f15653c8fa77["getContentConfigFromGlobal()"]
  157f6669_1b64_2b6d_ca39_b0f784c87ad2["vite-plugin-content-imports.ts"]
  0899dca1_e80f_b4eb_f265_f15653c8fa77 -->|defined in| 157f6669_1b64_2b6d_ca39_b0f784c87ad2
  d4749634_d021_a687_4265_4885c1ed7b3f["getEntryModuleBaseInfo()"]
  d4749634_d021_a687_4265_4885c1ed7b3f -->|calls| 0899dca1_e80f_b4eb_f265_f15653c8fa77
  style 0899dca1_e80f_b4eb_f265_f15653c8fa77 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/content/vite-plugin-content-imports.ts lines 369–404

async function getContentConfigFromGlobal() {
	const observable = globalContentConfigObserver.get();

	// Content config should be loaded before being accessed from Vite plugins
	if (observable.status === 'init') {
		throw new AstroError({
			...AstroErrorData.UnknownContentCollectionError,
			message: 'Content config failed to load.',
		});
	}
	if (observable.status === 'error') {
		// Throw here to bubble content config errors
		// to the error overlay in development
		throw observable.error;
	}

	let contentConfig: ContentConfig | undefined =
		observable.status === 'loaded' ? observable.config : undefined;
	if (observable.status === 'loading') {
		// Wait for config to load
		contentConfig = await new Promise((resolve) => {
			const unsubscribe = globalContentConfigObserver.subscribe((ctx) => {
				if (ctx.status === 'loaded') {
					resolve(ctx.config);
					unsubscribe();
				}
				if (ctx.status === 'error') {
					resolve(undefined);
					unsubscribe();
				}
			});
		});
	}

	return contentConfig;
}

Subdomains

Frequently Asked Questions

What does getContentConfigFromGlobal() do?
getContentConfigFromGlobal() is a function in the astro codebase, defined in packages/astro/src/content/vite-plugin-content-imports.ts.
Where is getContentConfigFromGlobal() defined?
getContentConfigFromGlobal() is defined in packages/astro/src/content/vite-plugin-content-imports.ts at line 369.
What calls getContentConfigFromGlobal()?
getContentConfigFromGlobal() is called by 1 function(s): getEntryModuleBaseInfo.

Analyze Your Own Codebase

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

Try Supermodel Free