Home / File/ static-paths.ts — astro Source File

static-paths.ts — astro Source File

Architecture documentation for static-paths.ts, a typescript file in the astro codebase. 7 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 7 imports 1 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  90a29f75_7e40_c6ca_4b3f_431e7f4d41c4["static-paths.ts"]
  a4f2698c_5256_262a_ba7c_f72b51878d10["../core/app/types.js"]
  90a29f75_7e40_c6ca_4b3f_431e7f4d41c4 --> a4f2698c_5256_262a_ba7c_f72b51878d10
  be18ffb8_46cb_5266_8b78_659c01f80146["../core/base-pipeline.js"]
  90a29f75_7e40_c6ca_4b3f_431e7f4d41c4 --> be18ffb8_46cb_5266_8b78_659c01f80146
  4c453c0b_17bb_ebc3_f7de_e2a632e42c1e["../types/public/integrations.js"]
  90a29f75_7e40_c6ca_4b3f_431e7f4d41c4 --> 4c453c0b_17bb_ebc3_f7de_e2a632e42c1e
  10d4e39f_edb6_3e34_aa93_ae1211e7da05["../types/public/internal.js"]
  90a29f75_7e40_c6ca_4b3f_431e7f4d41c4 --> 10d4e39f_edb6_3e34_aa93_ae1211e7da05
  c031332a_7d3e_d4f1_7183_71db94683f32["../../core/routing/params.js"]
  90a29f75_7e40_c6ca_4b3f_431e7f4d41c4 --> c031332a_7d3e_d4f1_7183_71db94683f32
  b3e8a9be_d20e_da21_abaa_3cb61c3f5a15["../core/routing/helpers.js"]
  90a29f75_7e40_c6ca_4b3f_431e7f4d41c4 --> b3e8a9be_d20e_da21_abaa_3cb61c3f5a15
  e4f1ecf5_7afe_e6c1_d3cd_7cbd7918b5e3["../../core/render/route-cache.js"]
  90a29f75_7e40_c6ca_4b3f_431e7f4d41c4 --> e4f1ecf5_7afe_e6c1_d3cd_7cbd7918b5e3
  style 90a29f75_7e40_c6ca_4b3f_431e7f4d41c4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { SSRManifest } from '../../core/app/types.js';
import type { Pipeline } from '../../core/base-pipeline.js';
import type { PathWithRoute } from '../../types/public/integrations.js';
import type { RouteData } from '../../types/public/internal.js';
import { stringifyParams } from '../../core/routing/params.js';
import { routeIsRedirect, routeIsFallback, getFallbackRoute } from '../../core/routing/helpers.js';
import { callGetStaticPaths } from '../../core/render/route-cache.js';

export type { PathWithRoute } from '../../types/public/integrations.js';

/**
 * Minimal interface for what StaticPaths needs from an App.
 * This allows adapters to pass any App-like object (BuildApp, NodeApp, etc).
 */
export interface StaticPathsApp {
	manifest: SSRManifest;
	pipeline: Pick<Pipeline, 'routeCache' | 'getComponentByRoute'>;
}

/**
 * Collects all static paths for prerendering.
 * Handles calling getStaticPaths on each route and populating the route cache.
 */
export class StaticPaths {
	#app: StaticPathsApp;

	constructor(app: StaticPathsApp) {
		this.#app = app;
	}

	/**
	 * Get all static paths for prerendering with their associated routes.
	 * This avoids needing to re-match routes later, which can be incorrect due to route priority.
	 */
	async getAll(): Promise<PathWithRoute[]> {
		const allPaths: PathWithRoute[] = [];
		const manifest = this.#app.manifest;

		// Collect routes to generate (mirrors retrieveRoutesToGenerate)
		const routesToGenerate: RouteData[] = [];
		for (const { routeData } of manifest.routes) {
			// Skip non-prerendered routes
			if (!routeData.prerender) continue;

			// Include redirects
			if (routeIsRedirect(routeData)) {
				routesToGenerate.push(routeData);
				continue;
			}

			// Include fallbacks if i18n has fallback configured
			if (routeIsFallback(routeData) && manifest.i18n?.fallback) {
				routesToGenerate.push(routeData);
				continue;
			}

			// Regular page
			routesToGenerate.push(routeData);
		}

// ... (70 more lines)

Domain

Subdomains

Classes

Dependencies

  • ../../core/render/route-cache.js
  • ../../core/routing/params.js
  • ../core/app/types.js
  • ../core/base-pipeline.js
  • ../core/routing/helpers.js
  • ../types/public/integrations.js
  • ../types/public/internal.js

Frequently Asked Questions

What does static-paths.ts do?
static-paths.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 static-paths.ts?
static-paths.ts defines 1 function(s): eachRouteInRouteData.
What does static-paths.ts depend on?
static-paths.ts imports 7 module(s): ../../core/render/route-cache.js, ../../core/routing/params.js, ../core/app/types.js, ../core/base-pipeline.js, ../core/routing/helpers.js, ../types/public/integrations.js, ../types/public/internal.js.
Where is static-paths.ts in the architecture?
static-paths.ts is located at packages/astro/src/runtime/prerender/static-paths.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/runtime/prerender).

Analyze Your Own Codebase

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

Try Supermodel Free