defineLiveCollection() — astro Function Reference
Architecture documentation for the defineLiveCollection() function in config.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 0fc0b3cd_d192_5ff3_ce5a_937f5bcee001["defineLiveCollection()"] be7d1eab_916b_90f9_3072_d169ed547abf["config.ts"] 0fc0b3cd_d192_5ff3_ce5a_937f5bcee001 -->|defined in| be7d1eab_916b_90f9_3072_d169ed547abf 65db2577_d5e4_a284_6317_4ddba4134e0d["getImporterFilename()"] 0fc0b3cd_d192_5ff3_ce5a_937f5bcee001 -->|calls| 65db2577_d5e4_a284_6317_4ddba4134e0d style 0fc0b3cd_d192_5ff3_ce5a_937f5bcee001 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/content/config.ts lines 116–174
export function defineLiveCollection<
L extends LiveLoader,
S extends BaseSchema | undefined = undefined,
>(config: LiveCollectionConfig<L, S>): LiveCollectionConfig<L, S> {
const importerFilename = getImporterFilename();
if (importerFilename && !importerFilename.includes('live.config')) {
throw new AstroError({
...AstroErrorData.LiveContentConfigError,
message: AstroErrorData.LiveContentConfigError.message(
'Live collections must be defined in a `src/live.config.ts` file.',
importerFilename ?? 'your content config file',
),
});
}
// Default to live content type if not specified
config.type ??= LIVE_CONTENT_TYPE;
if (config.type !== LIVE_CONTENT_TYPE) {
throw new AstroError({
...AstroErrorData.LiveContentConfigError,
message: AstroErrorData.LiveContentConfigError.message(
'Collections in a live config file must have a type of `live`.',
importerFilename,
),
});
}
if (!config.loader) {
throw new AstroError({
...AstroErrorData.LiveContentConfigError,
message: AstroErrorData.LiveContentConfigError.message(
'Live collections must have a `loader` defined.',
importerFilename,
),
});
}
if (!config.loader.loadCollection || !config.loader.loadEntry) {
throw new AstroError({
...AstroErrorData.LiveContentConfigError,
message: AstroErrorData.LiveContentConfigError.message(
'Live collection loaders must have `loadCollection()` and `loadEntry()` methods. Please check that you are not using a loader intended for build-time collections',
importerFilename,
),
});
}
if (typeof config.schema === 'function') {
throw new AstroError({
...AstroErrorData.LiveContentConfigError,
message: AstroErrorData.LiveContentConfigError.message(
'The schema cannot be a function for live collections. Please use a schema object instead.',
importerFilename,
),
});
}
return config;
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does defineLiveCollection() do?
defineLiveCollection() is a function in the astro codebase, defined in packages/astro/src/content/config.ts.
Where is defineLiveCollection() defined?
defineLiveCollection() is defined in packages/astro/src/content/config.ts at line 116.
What does defineLiveCollection() call?
defineLiveCollection() calls 1 function(s): getImporterFilename.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free