Home / Function/ syncContentCollections() — astro Function Reference

syncContentCollections() — astro Function Reference

Architecture documentation for the syncContentCollections() function in index.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  dd7413e0_8dca_f05b_441e_e3f39bb27100["syncContentCollections()"]
  cd488d83_5ad0_f34a_227f_731e9945a152["index.ts"]
  dd7413e0_8dca_f05b_441e_e3f39bb27100 -->|defined in| cd488d83_5ad0_f34a_227f_731e9945a152
  2523437b_c067_5714_7895_f8fb9bc10862["syncInternal()"]
  2523437b_c067_5714_7895_f8fb9bc10862 -->|calls| dd7413e0_8dca_f05b_441e_e3f39bb27100
  style dd7413e0_8dca_f05b_441e_e3f39bb27100 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/sync/index.ts lines 292–345

async function syncContentCollections(
	settings: AstroSettings,
	{ logger, fs, viteServer }: { logger: Logger; fs: typeof fsMod; viteServer: ViteDevServer },
): Promise<void> {
	try {
		const contentTypesGenerator = await createContentTypesGenerator({
			contentConfigObserver: globalContentConfigObserver,
			logger: logger,
			fs,
			settings,
			viteServer,
		});
		await contentTypesGenerator.init();

		const contentConfig = globalContentConfigObserver.get();
		if (contentConfig.status === 'error') {
			throw contentConfig.error;
		}
	} catch (e) {
		const safeError = createSafeError(e) as ErrorWithMetadata;
		if (isAstroError(e)) {
			throw e;
		}
		let configFile;
		try {
			const contentPaths = getContentPaths(
				settings.config,
				fs,
				settings.config.legacy?.collectionsBackwardsCompat,
			);
			if (contentPaths.config.exists) {
				const matches = /\/(src\/.+)/.exec(contentPaths.config.url.href);
				if (matches) {
					configFile = matches[1];
				}
			}
		} catch {
			// ignore
		}

		const hint = AstroUserError.is(e)
			? e.hint
			: AstroErrorData.GenerateContentTypesError.hint(configFile);
		throw new AstroError(
			{
				...AstroErrorData.GenerateContentTypesError,
				hint,
				message: AstroErrorData.GenerateContentTypesError.message(safeError.message),
				location: safeError.loc,
			},
			{ cause: e },
		);
	}
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does syncContentCollections() do?
syncContentCollections() is a function in the astro codebase, defined in packages/astro/src/core/sync/index.ts.
Where is syncContentCollections() defined?
syncContentCollections() is defined in packages/astro/src/core/sync/index.ts at line 292.
What calls syncContentCollections()?
syncContentCollections() is called by 1 function(s): syncInternal.

Analyze Your Own Codebase

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

Try Supermodel Free