Home / Function/ getFileInfo() — astro Function Reference

getFileInfo() — astro Function Reference

Architecture documentation for the getFileInfo() function in index.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  fe709afa_6f4d_d6d6_531e_e5a75b13f5a4["getFileInfo()"]
  298bcb8b_76f4_5bc3_f13f_87978f5034c8["index.ts"]
  fe709afa_6f4d_d6d6_531e_e5a75b13f5a4 -->|defined in| 298bcb8b_76f4_5bc3_f13f_87978f5034c8
  style fe709afa_6f4d_d6d6_531e_e5a75b13f5a4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/vite-plugin-utils/index.ts lines 11–29

export function getFileInfo(id: string, config: AstroConfig) {
	const sitePathname = appendForwardSlash(
		config.site ? new URL(config.base, config.site).pathname : config.base,
	);

	const fileId = id.split('?')[0];
	let fileUrl = fileId.includes('/pages/')
		? fileId
				.replace(/^.*?\/pages\//, sitePathname)
				.replace(/(?:\/index)?\.(?:md|markdown|mdown|mkdn|mkd|mdwn|astro)$/, '')
		: undefined;
	if (fileUrl && config.trailingSlash === 'always') {
		fileUrl = appendForwardSlash(fileUrl);
	}
	if (fileUrl && config.build.format === 'file') {
		fileUrl = appendExtension(fileUrl, 'html');
	}
	return { fileId, fileUrl };
}

Domain

Subdomains

Frequently Asked Questions

What does getFileInfo() do?
getFileInfo() is a function in the astro codebase, defined in packages/astro/src/vite-plugin-utils/index.ts.
Where is getFileInfo() defined?
getFileInfo() is defined in packages/astro/src/vite-plugin-utils/index.ts at line 11.

Analyze Your Own Codebase

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

Try Supermodel Free