Home / Function/ options() — astro Function Reference

options() — astro Function Reference

Architecture documentation for the options() function in content-layer.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  650841f3_f9b7_57f0_481a_fdc3aaab95b1["options()"]
  4a6efe25_e6e4_25af_3955_aede0d8f5983["ContentLayer"]
  650841f3_f9b7_57f0_481a_fdc3aaab95b1 -->|defined in| 4a6efe25_e6e4_25af_3955_aede0d8f5983
  b5de73ce_33fc_df1a_559d_4a8d2c6dde27["regenerateCollectionFileManifest()"]
  650841f3_f9b7_57f0_481a_fdc3aaab95b1 -->|calls| b5de73ce_33fc_df1a_559d_4a8d2c6dde27
  db471436_d97d_0fae_da24_bdb56669d945["simpleLoader()"]
  650841f3_f9b7_57f0_481a_fdc3aaab95b1 -->|calls| db471436_d97d_0fae_da24_bdb56669d945
  style 650841f3_f9b7_57f0_481a_fdc3aaab95b1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/content/content-layer.ts lines 174–347

	async #doSync(options: RefreshContentOptions) {
		let contentConfig = globalContentConfigObserver.get();
		const logger = this.#logger.forkIntegrationLogger('content');

		if (contentConfig?.status === 'loading') {
			contentConfig = await Promise.race<ReturnType<ContentObservable['get']>>([
				new Promise((resolve) => {
					const unsub = globalContentConfigObserver.subscribe((ctx) => {
						unsub();
						resolve(ctx);
					});
				}),
				new Promise((resolve) =>
					setTimeout(
						() =>
							resolve({ status: 'error', error: new Error('Content config loading timed out') }),
						5000,
					),
				),
			]);
		}

		switch (contentConfig?.status) {
			case 'loaded':
				// Proceed with sync
				break;
			case 'error':
				// Log error and skip sync
				logger.error(
					`Error loading content config. Skipping sync.\n${contentConfig.error.message}`,
				);
				return;
			case 'does-not-exist':
				// No content config file exists, skip sync silently
				return;
			case 'init':
			case 'loading':
			case undefined:
				// Should have loaded by now, but didn't
				logger.error(
					`Content config not loaded, skipping sync. Status was ${contentConfig?.status}`,
				);
				return;
		}

		logger.info('Syncing content');
		const {
			vite: _vite,
			integrations: _integrations,
			adapter: _adapter,
			...hashableConfig
		} = this.#settings.config;

		const astroConfigDigest = safeStringify(hashableConfig);

		const { digest: currentConfigDigest } = contentConfig.config;
		this.#lastConfigDigest = currentConfigDigest;

		let shouldClear = false;
		const previousConfigDigest = await this.#store.metaStore().get('content-config-digest');
		const previousAstroConfigDigest = await this.#store.metaStore().get('astro-config-digest');
		const previousAstroVersion = await this.#store.metaStore().get('astro-version');

		if (previousAstroConfigDigest && previousAstroConfigDigest !== astroConfigDigest) {
			logger.info('Astro config changed');
			shouldClear = true;
		}

		if (previousConfigDigest && previousConfigDigest !== currentConfigDigest) {
			logger.info('Content config changed');
			shouldClear = true;
		}
		if (previousAstroVersion && previousAstroVersion !== process.env.ASTRO_VERSION) {
			logger.info('Astro version changed');
			shouldClear = true;
		}
		if (shouldClear) {
			logger.info('Clearing content store');
			this.#store.clearAll();
		}
		if (process.env.ASTRO_VERSION) {

Subdomains

Frequently Asked Questions

What does options() do?
options() is a function in the astro codebase, defined in packages/astro/src/content/content-layer.ts.
Where is options() defined?
options() is defined in packages/astro/src/content/content-layer.ts at line 174.
What does options() call?
options() calls 2 function(s): regenerateCollectionFileManifest, simpleLoader.

Analyze Your Own Codebase

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

Try Supermodel Free