Home / Function/ getRouteGenerator() — astro Function Reference

getRouteGenerator() — astro Function Reference

Architecture documentation for the getRouteGenerator() function in generator.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  2da823ca_da3b_3728_ec76_2cea8f93934e["getRouteGenerator()"]
  f66463aa_0743_20f2_0ef3_7ae29013020e["generator.ts"]
  2da823ca_da3b_3728_ec76_2cea8f93934e -->|defined in| f66463aa_0743_20f2_0ef3_7ae29013020e
  fa15888b_4a0c_4f96_867c_f23eb99d0576["sanitizeParams()"]
  2da823ca_da3b_3728_ec76_2cea8f93934e -->|calls| fa15888b_4a0c_4f96_867c_f23eb99d0576
  7242b7d7_2c3a_ea6c_bba0_c245bbd1dd26["getSegment()"]
  2da823ca_da3b_3728_ec76_2cea8f93934e -->|calls| 7242b7d7_2c3a_ea6c_bba0_c245bbd1dd26
  style 2da823ca_da3b_3728_ec76_2cea8f93934e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/routing/manifest/generator.ts lines 49–67

export function getRouteGenerator(
	segments: RoutePart[][],
	addTrailingSlash: AstroConfig['trailingSlash'],
): RouteGenerator {
	return (params?: any): string => {
		const sanitizedParams = sanitizeParams(params);

		// Unless trailingSlash config is set to 'always', don't automatically append it.
		let trailing: '/' | '' = '';
		if (addTrailingSlash === 'always' && segments.length) {
			trailing = '/';
		}

		const path =
			segments.map((segment) => getSegment(segment, sanitizedParams)).join('') + trailing;

		return path || '/';
	};
}

Domain

Subdomains

Frequently Asked Questions

What does getRouteGenerator() do?
getRouteGenerator() is a function in the astro codebase, defined in packages/astro/src/core/routing/manifest/generator.ts.
Where is getRouteGenerator() defined?
getRouteGenerator() is defined in packages/astro/src/core/routing/manifest/generator.ts at line 49.
What does getRouteGenerator() call?
getRouteGenerator() calls 2 function(s): getSegment, sanitizeParams.

Analyze Your Own Codebase

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

Try Supermodel Free