chainRoutesOf
The routes of a rendered chain that the metadata reads, outermost first, from matches and their specs.
The routes of a rendered chain that the metadata reads, outermost first, from matches and their specs.
Import#
ts
import { chainRoutesOf } from "@shadow-js/dusk/server";
Signature#
ts
function chainRoutesOf(
matches: readonly RenderedMatch[],
specOf: (id: string) => SpecExports | undefined,
): ChainRoute[]
Parameters#
| Name | Description |
|---|---|
matches |
The rendered matches (a not-found route is skipped). |
specOf |
The spec of a route id. |
Returns#
One chain route per route match with a spec.
Examples#
ts
import { chainRoutesOf } from the "@shadow-js/dusk/server" subpath;
const matches = [{ kind: "route", id: "docs", pattern: "/docs", params: {}, loaderData: undefined, depth: 0 }];
chainRoutesOf(matches, () => ({ metadata: { title: "Docs" } })).map((route) => route.id); // ["docs"]