Home / Function/ createGetLiveEntry() — astro Function Reference

createGetLiveEntry() — astro Function Reference

Architecture documentation for the createGetLiveEntry() function in runtime.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  8a71210b_d179_6942_4f98_1fa03aecbe8f["createGetLiveEntry()"]
  73d13646_8e80_972f_3adc_f28448b64e4d["runtime.ts"]
  8a71210b_d179_6942_4f98_1fa03aecbe8f -->|defined in| 73d13646_8e80_972f_3adc_f28448b64e4d
  45b9cc16_8326_90a1_a556_3b8ba93f389c["parseLiveEntry()"]
  8a71210b_d179_6942_4f98_1fa03aecbe8f -->|calls| 45b9cc16_8326_90a1_a556_3b8ba93f389c
  style 8a71210b_d179_6942_4f98_1fa03aecbe8f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/content/runtime.ts lines 375–440

export function createGetLiveEntry({
	liveCollections,
}: {
	liveCollections: LiveCollectionConfigMap;
}) {
	return async function getLiveEntry(
		collection: string,
		lookup: string | Record<string, unknown>,
	): Promise<LiveDataEntryResult> {
		if (!(collection in liveCollections)) {
			return {
				error: new LiveCollectionError(
					collection,
					`Collection "${collection}" is not a live collection. Use getCollection() instead of getLiveEntry() to load regular content collections.`,
				),
			};
		}

		try {
			const lookupObject = {
				filter: typeof lookup === 'string' ? { id: lookup } : lookup,
				collection,
			};

			let entry = await (
				liveCollections[collection].loader as LiveLoader<
					Record<string, unknown>,
					Record<string, unknown>
				>
			)?.loadEntry?.(lookupObject);

			// Check if loader returned an error
			if (entry && 'error' in entry) {
				return { error: entry.error };
			}

			if (!entry) {
				return {
					error: new LiveEntryNotFoundError(collection, lookup),
				};
			}

			const { schema } = liveCollections[collection];
			if (schema) {
				const result = await parseLiveEntry(entry, schema, collection);
				if (result.error) {
					return { error: result.error };
				}
				entry = result.entry!;
			}

			return {
				entry: entry,
				cacheHint: entry.cacheHint,
			};
		} catch (error) {
			return {
				error: new LiveCollectionError(
					collection,
					`Unexpected error loading entry ${collection} → ${typeof lookup === 'string' ? lookup : JSON.stringify(lookup)}`,
					error as Error,
				),
			};
		}
	};
}

Subdomains

Frequently Asked Questions

What does createGetLiveEntry() do?
createGetLiveEntry() is a function in the astro codebase, defined in packages/astro/src/content/runtime.ts.
Where is createGetLiveEntry() defined?
createGetLiveEntry() is defined in packages/astro/src/content/runtime.ts at line 375.
What does createGetLiveEntry() call?
createGetLiveEntry() calls 1 function(s): parseLiveEntry.

Analyze Your Own Codebase

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

Try Supermodel Free