Home / Function/ createBaseSettings() — astro Function Reference

createBaseSettings() — astro Function Reference

Architecture documentation for the createBaseSettings() function in settings.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  47934f85_fc58_9c44_0089_601e41df2278["createBaseSettings()"]
  b5841de7_4ddd_6101_37ae_9e92ac43fb0f["settings.ts"]
  47934f85_fc58_9c44_0089_601e41df2278 -->|defined in| b5841de7_4ddd_6101_37ae_9e92ac43fb0f
  ade7b9f5_5373_99b0_0e0d_1038e888f26c["createSettings()"]
  ade7b9f5_5373_99b0_0e0d_1038e888f26c -->|calls| 47934f85_fc58_9c44_0089_601e41df2278
  style 47934f85_fc58_9c44_0089_601e41df2278 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/config/settings.ts lines 22–165

export function createBaseSettings(
	config: AstroConfig,
	logLevel: AstroInlineConfig['logLevel'],
): AstroSettings {
	const { contentDir } = getContentPaths(
		config,
		undefined,
		config.legacy?.collectionsBackwardsCompat,
	);
	const dotAstroDir = new URL('.astro/', config.root);
	const preferences = createPreferences(config, dotAstroDir);
	return {
		config,
		preferences,
		tsConfig: undefined,
		tsConfigPath: undefined,
		adapter: undefined,
		prerenderer: undefined,
		injectedRoutes: [],
		resolvedInjectedRoutes: [],
		pageExtensions: ['.astro', '.html', ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS],
		contentEntryTypes: [markdownContentEntryType],
		dataEntryTypes: [
			{
				extensions: ['.json'],
				getEntryInfo({ contents, fileUrl }) {
					if (contents === undefined || contents === '') return { data: {} };

					const pathRelToContentDir = path.relative(
						fileURLToPath(contentDir),
						fileURLToPath(fileUrl),
					);
					let data;
					try {
						data = JSON.parse(contents);
					} catch (e) {
						throw new AstroError({
							...AstroErrorData.DataCollectionEntryParseError,
							message: AstroErrorData.DataCollectionEntryParseError.message(
								pathRelToContentDir,
								e instanceof Error ? e.message : 'contains invalid JSON.',
							),
							location: { file: fileUrl.pathname },
							stack: e instanceof Error ? e.stack : undefined,
						});
					}

					if (data == null || typeof data !== 'object') {
						throw new AstroError({
							...AstroErrorData.DataCollectionEntryParseError,
							message: AstroErrorData.DataCollectionEntryParseError.message(
								pathRelToContentDir,
								'data is not an object.',
							),
							location: { file: fileUrl.pathname },
						});
					}

					return { data };
				},
			},
			{
				extensions: ['.yaml', '.yml'],
				getEntryInfo({ contents, fileUrl }) {
					try {
						const data = yaml.load(contents, { filename: fileURLToPath(fileUrl) });
						const rawData = contents;

						return { data, rawData };
					} catch (e) {
						const pathRelToContentDir = path.relative(
							fileURLToPath(contentDir),
							fileURLToPath(fileUrl),
						);
						const formattedError = isYAMLException(e)
							? formatYAMLException(e)
							: new Error('contains invalid YAML.');

						throw new AstroError({
							...AstroErrorData.DataCollectionEntryParseError,
							message: AstroErrorData.DataCollectionEntryParseError.message(

Domain

Subdomains

Called By

Frequently Asked Questions

What does createBaseSettings() do?
createBaseSettings() is a function in the astro codebase, defined in packages/astro/src/core/config/settings.ts.
Where is createBaseSettings() defined?
createBaseSettings() is defined in packages/astro/src/core/config/settings.ts at line 22.
What calls createBaseSettings()?
createBaseSettings() is called by 1 function(s): createSettings.

Analyze Your Own Codebase

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

Try Supermodel Free