loadContentConfig() — astro Function Reference
Architecture documentation for the loadContentConfig() function in utils.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 6c793dbe_77b3_414d_aedb_6d44b431caa5["loadContentConfig()"] 7a09e708_c090_71c0_8138_7343699b1865["utils.ts"] 6c793dbe_77b3_414d_aedb_6d44b431caa5 -->|defined in| 7a09e708_c090_71c0_8138_7343699b1865 6820fa7c_c0e9_20cf_23d1_0ee1afd42476["reloadContentConfigObserver()"] 6820fa7c_c0e9_20cf_23d1_0ee1afd42476 -->|calls| 6c793dbe_77b3_414d_aedb_6d44b431caa5 38ea7ddd_a3ec_4810_fa09_65e574335368["getContentPaths()"] 6c793dbe_77b3_414d_aedb_6d44b431caa5 -->|calls| 38ea7ddd_a3ec_4810_fa09_65e574335368 style 6c793dbe_77b3_414d_aedb_6d44b431caa5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/content/utils.ts lines 493–540
async function loadContentConfig({
fs,
settings,
environment,
}: {
fs: typeof fsMod;
settings: AstroSettings;
environment: RunnableDevEnvironment;
}): Promise<ContentConfig | undefined> {
const contentPaths = getContentPaths(
settings.config,
fs,
settings.config.legacy?.collectionsBackwardsCompat,
);
if (!contentPaths.config.exists) {
return undefined;
}
const configPathname = fileURLToPath(contentPaths.config.url);
const unparsedConfig = await environment.runner.import(configPathname);
const config = contentConfigParser.safeParse(unparsedConfig);
if (config.success) {
// Generate a digest of the config file so we can invalidate the cache if it changes
const hasher = await xxhash();
const digest = hasher.h64ToString(await fs.promises.readFile(configPathname, 'utf-8'));
return { ...config.data, digest };
} else {
const message = config.error.issues
.map((issue) => ` → ${colors.green(issue.path.join('.'))}: ${colors.red(issue.message)}`)
.join('\n');
console.error(
`${colors.green('[content]')} There was a problem with your content config:\n\n${message}\n`,
);
const liveCollections = Object.entries(unparsedConfig.collections ?? {}).filter(
([, collection]: [string, any]) => collection?.type === LIVE_CONTENT_TYPE,
);
if (liveCollections.length > 0) {
throw new AstroError({
...AstroErrorData.LiveContentConfigError,
message: AstroErrorData.LiveContentConfigError.message(
'Live collections must be defined in a `src/live.config.ts` file.',
path.relative(fileURLToPath(settings.config.root), configPathname),
),
});
}
return undefined;
}
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does loadContentConfig() do?
loadContentConfig() is a function in the astro codebase, defined in packages/astro/src/content/utils.ts.
Where is loadContentConfig() defined?
loadContentConfig() is defined in packages/astro/src/content/utils.ts at line 493.
What does loadContentConfig() call?
loadContentConfig() calls 1 function(s): getContentPaths.
What calls loadContentConfig()?
loadContentConfig() is called by 1 function(s): reloadContentConfigObserver.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free