pluginPage() — astro Function Reference
Architecture documentation for the pluginPage() function in page.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 362c7ce9_87a0_8fb6_b81e_f15a61bfd341["pluginPage()"] 0ca4b994_0ce6_e5b5_9813_c64eb15ad76e["page.ts"] 362c7ce9_87a0_8fb6_b81e_f15a61bfd341 -->|defined in| 0ca4b994_0ce6_e5b5_9813_c64eb15ad76e 3cd7689e_fc3b_699b_a4ad_d3b26eeae0fd["getComponentFromVirtualModulePageName()"] 362c7ce9_87a0_8fb6_b81e_f15a61bfd341 -->|calls| 3cd7689e_fc3b_699b_a4ad_d3b26eeae0fd style 362c7ce9_87a0_8fb6_b81e_f15a61bfd341 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/vite-plugin-pages/page.ts lines 13–65
export function pluginPage({ routesList }: PagePluginOptions): VitePlugin {
return {
name: '@astro/plugin-page',
applyToEnvironment(environment) {
return (
environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr ||
environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.prerender
);
},
resolveId: {
filter: {
id: new RegExp(`^${VIRTUAL_PAGE_MODULE_ID}`),
},
handler(id) {
return VIRTUAL_PAGE_RESOLVED_MODULE_ID + id.slice(VIRTUAL_PAGE_MODULE_ID.length);
},
},
load: {
filter: {
id: new RegExp(`^${VIRTUAL_PAGE_RESOLVED_MODULE_ID}`),
},
handler(id) {
const componentPath = getComponentFromVirtualModulePageName(
VIRTUAL_PAGE_RESOLVED_MODULE_ID,
id,
);
// Skip default components (404, server islands, etc.)
if (DEFAULT_COMPONENTS.some((component) => componentPath === component)) {
return { code: '' };
}
// Find the route(s) that use this component
const routes = routesList.routes.filter((route) => route.component === componentPath);
for (const route of routes) {
if (routeIsRedirect(route)) {
continue;
}
const astroModuleId = prependForwardSlash(componentPath);
const imports: string[] = [];
const exports: string[] = [];
imports.push(`import * as _page from ${JSON.stringify(astroModuleId)};`);
exports.push(`export const page = () => _page`);
return { code: `${imports.join('\n')}\n${exports.join('\n')}` };
}
},
},
};
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does pluginPage() do?
pluginPage() is a function in the astro codebase, defined in packages/astro/src/vite-plugin-pages/page.ts.
Where is pluginPage() defined?
pluginPage() is defined in packages/astro/src/vite-plugin-pages/page.ts at line 13.
What does pluginPage() call?
pluginPage() calls 1 function(s): getComponentFromVirtualModulePageName.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free