Kind: Function
Source: src/helper/route/index.ts
Part of: Helper
Get the basePath of the as-is route specified by routing.
baseRoutePath returns the base path for the route described by routing. Use it when route-aware code needs the declared path without duplicating route-path handling.
Signature
tsfunction baseRoutePath(c: Context, index: number): string
Parameters
| Name | Type |
|---|---|
c | Context |
index | number |
Returns: string
Diagram
mermaidgraph LR A[Routing value] --> B[baseRoutePath] B --> C[Base route path]
Usage
tsimport { baseRoutePath } from '@/helper/route';
const routing = '/articles/[slug]';
const path = baseRoutePath(routing);
// Use the base route path in route-aware logic.
console.log(path);
AI Coding Instructions
- Pass the routing value from the route configuration rather than rebuilding its path in calling code.
- Keep route parsing and base-path extraction inside
baseRoutePath. - Preserve dynamic route segments when passing route definitions to this function.
- Update callers if the routing value format changes.
Was this page helpful?