route-cache.ts — astro Source File
Architecture documentation for route-cache.ts, a typescript file in the astro codebase. 8 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 2f0e5468_ae4d_5ec1_61b2_b1f585819620["route-cache.ts"] e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"] 2f0e5468_ae4d_5ec1_61b2_b1f585819620 --> e9b74c5a_8d34_34a7_e196_5e41b87214aa 135a8084_d596_67c2_9209_cca6693604e6["../types/public/common.js"] 2f0e5468_ae4d_5ec1_61b2_b1f585819620 --> 135a8084_d596_67c2_9209_cca6693604e6 c32d12e2_d85e_28c0_eea7_9b29629857e0["../types/public/config.js"] 2f0e5468_ae4d_5ec1_61b2_b1f585819620 --> c32d12e2_d85e_28c0_eea7_9b29629857e0 10d4e39f_edb6_3e34_aa93_ae1211e7da05["../types/public/internal.js"] 2f0e5468_ae4d_5ec1_61b2_b1f585819620 --> 10d4e39f_edb6_3e34_aa93_ae1211e7da05 d3861967_b647_84d2_ff48_15013353bd56["../core/logger/core.js"] 2f0e5468_ae4d_5ec1_61b2_b1f585819620 --> d3861967_b647_84d2_ff48_15013353bd56 c031332a_7d3e_d4f1_7183_71db94683f32["../../core/routing/params.js"] 2f0e5468_ae4d_5ec1_61b2_b1f585819620 --> c031332a_7d3e_d4f1_7183_71db94683f32 da1a3b3b_edd7_26bf_8041_c6e9bb29705c["./validation.js"] 2f0e5468_ae4d_5ec1_61b2_b1f585819620 --> da1a3b3b_edd7_26bf_8041_c6e9bb29705c e5a26a0d_d755_19ba_f1d7_ec9b92b2fe52["./paginate.js"] 2f0e5468_ae4d_5ec1_61b2_b1f585819620 --> e5a26a0d_d755_19ba_f1d7_ec9b92b2fe52 style 2f0e5468_ae4d_5ec1_61b2_b1f585819620 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { ComponentInstance } from '../../types/astro.js';
import type {
GetStaticPathsItem,
GetStaticPathsResult,
GetStaticPathsResultKeyed,
PaginateFunction,
Params,
} from '../../types/public/common.js';
import type { AstroConfig, RuntimeMode } from '../../types/public/config.js';
import type { RouteData } from '../../types/public/internal.js';
import type { Logger } from '../logger/core.js';
import { stringifyParams } from '../routing/params.js';
import { validateDynamicRouteModule, validateGetStaticPathsResult } from '../routing/validation.js';
import { generatePaginateFunction } from './paginate.js';
interface CallGetStaticPathsOptions {
mod: ComponentInstance | undefined;
route: RouteData;
routeCache: RouteCache;
ssr: boolean;
base: AstroConfig['base'];
trailingSlash: AstroConfig['trailingSlash'];
}
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?
// ... (78 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- ../../core/routing/params.js
- ../core/logger/core.js
- ../types/astro.js
- ../types/public/common.js
- ../types/public/config.js
- ../types/public/internal.js
- ./paginate.js
- ./validation.js
Source
Frequently Asked Questions
What does route-cache.ts do?
route-cache.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in route-cache.ts?
route-cache.ts defines 2 function(s): callGetStaticPaths, findPathItemByKey.
What does route-cache.ts depend on?
route-cache.ts imports 8 module(s): ../../core/routing/params.js, ../core/logger/core.js, ../types/astro.js, ../types/public/common.js, ../types/public/config.js, ../types/public/internal.js, ./paginate.js, ./validation.js.
Where is route-cache.ts in the architecture?
route-cache.ts is located at packages/astro/src/core/render/route-cache.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/core/render).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free