getFileInfo() — astro Function Reference
Architecture documentation for the getFileInfo() function in utils.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD b08b2af1_220d_e8ce_fa35_c6838e614f4e["getFileInfo()"] 579be117_6aa8_f4e4_0e48_c4a41ab4204a["utils.ts"] b08b2af1_220d_e8ce_fa35_c6838e614f4e -->|defined in| 579be117_6aa8_f4e4_0e48_c4a41ab4204a ce8c3869_e144_604f_1380_c3c27dc71951["appendForwardSlash()"] b08b2af1_220d_e8ce_fa35_c6838e614f4e -->|calls| ce8c3869_e144_604f_1380_c3c27dc71951 style b08b2af1_220d_e8ce_fa35_c6838e614f4e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/integrations/mdx/src/utils.ts lines 19–45
export function getFileInfo(id: string, config: AstroConfig): FileInfo {
const sitePathname = appendForwardSlash(
config.site ? new URL(config.base, config.site).pathname : config.base,
);
// Try to grab the file's actual URL
let url: URL | undefined = undefined;
try {
url = new URL(`file://${id}`);
} catch {}
const fileId = id.split('?')[0];
let fileUrl: string;
const isPage = fileId.includes('/pages/');
if (isPage) {
fileUrl = fileId.replace(/^.*?\/pages\//, sitePathname).replace(/(?:\/index)?\.mdx$/, '');
} else if (url?.pathname.startsWith(config.root.pathname)) {
fileUrl = url.pathname.slice(config.root.pathname.length);
} else {
fileUrl = fileId;
}
if (fileUrl && config.trailingSlash === 'always') {
fileUrl = appendForwardSlash(fileUrl);
}
return { fileId, fileUrl };
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does getFileInfo() do?
getFileInfo() is a function in the astro codebase, defined in packages/integrations/mdx/src/utils.ts.
Where is getFileInfo() defined?
getFileInfo() is defined in packages/integrations/mdx/src/utils.ts at line 19.
What does getFileInfo() call?
getFileInfo() calls 1 function(s): appendForwardSlash.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free