callGetStaticPaths() — astro Function Reference
Architecture documentation for the callGetStaticPaths() function in route-cache.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 048344ff_c9c7_2ece_8c6f_f290d78d8649["callGetStaticPaths()"] 2f0e5468_ae4d_5ec1_61b2_b1f585819620["route-cache.ts"] 048344ff_c9c7_2ece_8c6f_f290d78d8649 -->|defined in| 2f0e5468_ae4d_5ec1_61b2_b1f585819620 5182e483_bd8d_1680_67cd_f665386c9d74["get()"] 048344ff_c9c7_2ece_8c6f_f290d78d8649 -->|calls| 5182e483_bd8d_1680_67cd_f665386c9d74 1908c3bf_4f4b_9edf_2e46_d7f8234fb45b["set()"] 048344ff_c9c7_2ece_8c6f_f290d78d8649 -->|calls| 1908c3bf_4f4b_9edf_2e46_d7f8234fb45b style 048344ff_c9c7_2ece_8c6f_f290d78d8649 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/render/route-cache.ts lines 26–78
export async function callGetStaticPaths({
mod,
route,
routeCache,
ssr,
base,
trailingSlash,
}: CallGetStaticPathsOptions): Promise<GetStaticPathsResultKeyed> {
const cached = routeCache.get(route);
if (!mod) {
throw new Error('This is an error caused by Astro and not your code. Please file an issue.');
}
if (cached?.staticPaths) {
return cached.staticPaths;
}
validateDynamicRouteModule(mod, { ssr, route });
// No static paths in SSR mode. Return an empty RouteCacheEntry.
if (ssr && !route.prerender) {
const entry: GetStaticPathsResultKeyed = Object.assign([], { keyed: new Map() });
routeCache.set(route, { ...cached, staticPaths: entry });
return entry;
}
let staticPaths: GetStaticPathsResult = [];
// Add a check here to make TypeScript happy.
// This is already checked in validateDynamicRouteModule().
if (!mod.getStaticPaths) {
throw new Error('Unexpected Error.');
}
// Calculate your static paths.
staticPaths = await mod.getStaticPaths({
// Q: Why the cast?
// A: So users downstream can have nicer typings, we have to make some sacrifice in our internal typings, which necessitate a cast here
paginate: generatePaginateFunction(route, base, trailingSlash) as PaginateFunction,
routePattern: route.route,
});
validateGetStaticPathsResult(staticPaths, route);
const keyedStaticPaths = staticPaths as GetStaticPathsResultKeyed;
keyedStaticPaths.keyed = new Map<string, GetStaticPathsItem>();
for (const sp of keyedStaticPaths) {
const paramsKey = stringifyParams(sp.params, route, trailingSlash);
keyedStaticPaths.keyed.set(paramsKey, sp);
}
routeCache.set(route, { ...cached, staticPaths: keyedStaticPaths });
return keyedStaticPaths;
}
Domain
Subdomains
Source
Frequently Asked Questions
What does callGetStaticPaths() do?
callGetStaticPaths() is a function in the astro codebase, defined in packages/astro/src/core/render/route-cache.ts.
Where is callGetStaticPaths() defined?
callGetStaticPaths() is defined in packages/astro/src/core/render/route-cache.ts at line 26.
What does callGetStaticPaths() call?
callGetStaticPaths() calls 2 function(s): get, set.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free