@sarimarcus/content-sites-core 0.31.7 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All packages in the platform release in lockstep; entries are per release version.
4
4
 
5
+ ## 0.32.0 (2026-10-09)
6
+
7
+ - `./config` adds `resolveConfig`, `siteConfigValues`, `mergeConfig` and `hasCapability`: the vertical defaults → site settings → props precedence (objects merge key by key, arrays and every other value replace). `./types` adds `ConfigValue`, `ConfigLayer` and optional `SiteConfig.capabilities`/`defaults`/`settings`; `./url` adds `routePath`, `DEFAULT_ROUTES`, `RouteKind` and `SiteRoutes` (SLA-2991).
8
+
9
+ ### Breaking
10
+
11
+ - `touristTripBuilder` and `TouristTripOptions` are removed from `./schema` (deprecated in 0.22.2); import them from `@sarimarcus/content-sites-tourism/schema`. `scripts/platform/migrations/remove-deprecated.mjs` asserts no call site (SLA-2991).
12
+ - `keyBySlug` is removed from `./url`; `buildImageMap` is the same function. It was never deprecated first: the codemod `scripts/platform/migrations/remove-deprecated.mjs` renames every call site (Dark Skies, 4 imports), so no release leaves a site broken (SLA-2991).
13
+ - `VerticalDefinition` gains required `defaults` and `capabilities` (`{}` and `[]` when a vertical sets none); the factory's `vertical.json` loader (`scripts/platform/lib/definitions.mjs`) fills them, and no site builds a definition by hand (SLA-2991).
14
+
5
15
  ## 0.31.7 (2026-10-09)
6
16
 
7
17
  - No changes; lockstep release with ui and tourism (SLA-3024, SLA-3025, SLA-3026).
@@ -3,3 +3,4 @@ export type { SiteConfigOptions, SitemapRule, PagefindIntegration } from './site
3
3
  export { outboundLinkRel } from './outboundLinkRel.ts';
4
4
  export type { OutboundLinkRelOptions } from './outboundLinkRel.ts';
5
5
  export { latestGuideDate, guideDateMap, guidePublishDates } from './guideDates.ts';
6
+ export { mergeConfig, resolveConfig, siteConfigValues, hasCapability } from './precedence.ts';
@@ -2,3 +2,4 @@
2
2
  export { defineSiteConfig, buildLastmodMap, sitemapSerialize, PAGEFIND_EXCLUDE_SELECTORS } from "./siteConfig.js";
3
3
  export { outboundLinkRel } from "./outboundLinkRel.js";
4
4
  export { latestGuideDate, guideDateMap, guidePublishDates } from "./guideDates.js";
5
+ export { mergeConfig, resolveConfig, siteConfigValues, hasCapability } from "./precedence.js";
@@ -0,0 +1,15 @@
1
+ import type { ConfigLayer, SiteConfig } from '../types/index.ts';
2
+ /**
3
+ * `over` laid on `base`: a key `over` leaves undefined keeps the base value; an object merges key by key with the same
4
+ * rule; anything else (an array included) replaces the base value whole. Arrays never merge.
5
+ */
6
+ export declare function mergeConfig<T extends ConfigLayer>(base: T, over: ConfigLayer | undefined): T;
7
+ /**
8
+ * The layers in precedence order, lowest first: the vertical's `defaults`, then the site's `settings` (both from
9
+ * `site.generated.ts`), then the props of the call. Later wins key by key; arrays are replaced, never merged.
10
+ */
11
+ export declare function resolveConfig<T extends ConfigLayer = ConfigLayer>(...layers: Array<ConfigLayer | undefined>): T;
12
+ /** A site's effective configuration: its vertical's defaults, then its own settings, then `props`. */
13
+ export declare function siteConfigValues<T extends ConfigLayer = ConfigLayer>(site: Pick<SiteConfig, 'defaults' | 'settings'>, props?: ConfigLayer): T;
14
+ /** Whether the site's vertical declares `capability`. */
15
+ export declare function hasCapability(site: Pick<SiteConfig, 'capabilities'>, capability: string): boolean;
@@ -0,0 +1,32 @@
1
+ const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
2
+ /**
3
+ * `over` laid on `base`: a key `over` leaves undefined keeps the base value; an object merges key by key with the same
4
+ * rule; anything else (an array included) replaces the base value whole. Arrays never merge.
5
+ */
6
+ export function mergeConfig(base, over) {
7
+ if (!over)
8
+ return base;
9
+ const out = { ...base };
10
+ for (const [key, value] of Object.entries(over)) {
11
+ if (value === undefined)
12
+ continue;
13
+ const prior = out[key];
14
+ out[key] = isRecord(prior) && isRecord(value) ? mergeConfig(prior, value) : value;
15
+ }
16
+ return out;
17
+ }
18
+ /**
19
+ * The layers in precedence order, lowest first: the vertical's `defaults`, then the site's `settings` (both from
20
+ * `site.generated.ts`), then the props of the call. Later wins key by key; arrays are replaced, never merged.
21
+ */
22
+ export function resolveConfig(...layers) {
23
+ return layers.reduce((acc, layer) => mergeConfig(acc, layer), {});
24
+ }
25
+ /** A site's effective configuration: its vertical's defaults, then its own settings, then `props`. */
26
+ export function siteConfigValues(site, props) {
27
+ return resolveConfig(site.defaults, site.settings, props);
28
+ }
29
+ /** Whether the site's vertical declares `capability`. */
30
+ export function hasCapability(site, capability) {
31
+ return site.capabilities?.includes(capability) ?? false;
32
+ }
@@ -15,7 +15,7 @@ export { buildBreadcrumbList, buildWebPageNode, assembleGraph, finalizeGraph } f
15
15
  export type { BreadcrumbInput, PageInput, AssembleOptions } from './graph.ts';
16
16
  export { faqPageBuilder, articleBuilder, collectionPageBuilder, itemListBuilder, howToBuilder, aboutPageBuilder, contactPageBuilder, personBuilder, aggregateOfferBuilder, touristDestinationBuilder, organizationBuilder, } from './pages.ts';
17
17
  export type { ArticleOptions, CollectionPageOptions, ItemListOptions, AboutPageOptions, PersonOptions, AggregateOfferOptions, TouristDestinationFields, } from './pages.ts';
18
- export { hotelBuilder, activityBuilder, touristTripBuilder } from './places.ts';
19
- export type { HotelOptions, ActivityOptions, TouristTripOptions } from './places.ts';
18
+ export { hotelBuilder, activityBuilder } from './places.ts';
19
+ export type { HotelOptions, ActivityOptions } from './places.ts';
20
20
  export { eventBuilder, eventItemListBuilder } from './events.ts';
21
21
  export type { EventPolicy, EventOptions, EventItemListOptions } from './events.ts';
@@ -7,5 +7,5 @@ export { renderSchemaPolicy } from "./policy.js";
7
7
  export { offer, placeNode, siteOrganizationNode, siteWebsiteNode } from "./nodes.js";
8
8
  export { buildBreadcrumbList, buildWebPageNode, assembleGraph, finalizeGraph } from "./graph.js";
9
9
  export { faqPageBuilder, articleBuilder, collectionPageBuilder, itemListBuilder, howToBuilder, aboutPageBuilder, contactPageBuilder, personBuilder, aggregateOfferBuilder, touristDestinationBuilder, organizationBuilder, } from "./pages.js";
10
- export { hotelBuilder, activityBuilder, touristTripBuilder } from "./places.js";
10
+ export { hotelBuilder, activityBuilder } from "./places.js";
11
11
  export { eventBuilder, eventItemListBuilder } from "./events.js";
@@ -18,13 +18,3 @@ export interface ActivityOptions {
18
18
  }
19
19
  /** TouristAttraction at route `activity`; the street falls back to `meetingPoint`. */
20
20
  export declare function activityBuilder(options: ActivityOptions): SchemaBuilder;
21
- export interface TouristTripOptions {
22
- touristType?: string;
23
- offerDescription?: string;
24
- currency?: string;
25
- }
26
- /**
27
- * A free self-guided TouristTrip at route `walk`, its stops as the itinerary.
28
- * @deprecated Tourism-only: import `touristTripBuilder` from `@sarimarcus/content-sites-tourism/schema` (SLA-2918).
29
- */
30
- export declare function touristTripBuilder(options?: TouristTripOptions): SchemaBuilder;
@@ -41,29 +41,3 @@ export function activityBuilder(options) {
41
41
  offers: offers && data.priceFrom !== undefined ? offer(data.priceFrom, currency) : undefined,
42
42
  });
43
43
  }
44
- /**
45
- * A free self-guided TouristTrip at route `walk`, its stops as the itinerary.
46
- * @deprecated Tourism-only: import `touristTripBuilder` from `@sarimarcus/content-sites-tourism/schema` (SLA-2918).
47
- */
48
- export function touristTripBuilder(options = {}) {
49
- const { touristType = 'Cultural', offerDescription = 'Self-guided walking tour — free', currency = 'EUR' } = options;
50
- return (data, ctx) => placeNode(ctx, data, 'TouristTrip', 'walk', {
51
- touristType: data.theme || touristType,
52
- offers: offer(0, currency, { description: offerDescription }),
53
- itinerary: {
54
- '@type': 'ItemList',
55
- numberOfItems: data.stops?.length || 0,
56
- itemListElement: (data.stops || []).map((stop, i) => ({
57
- '@type': 'ListItem',
58
- position: i + 1,
59
- item: {
60
- '@type': 'TouristAttraction',
61
- name: stop.name,
62
- description: stop.description,
63
- geo: geoCoordinates(stop.coordinates),
64
- ...(stop.slug && stop.type !== 'landmark' ? { url: ctx.route(stop.type, stop.slug) } : {}),
65
- },
66
- })),
67
- },
68
- });
69
- }
@@ -10,6 +10,14 @@ export type CityPlaces = {
10
10
  export type WorldwidePlaces = {
11
11
  mode: 'worldwide';
12
12
  };
13
+ /** A JSON value a vertical default or a site setting may hold. */
14
+ export type ConfigValue = string | number | boolean | null | readonly ConfigValue[] | {
15
+ readonly [key: string]: ConfigValue;
16
+ };
17
+ /** One configuration layer: vertical `defaults`, site `settings`, or the props of a call. Precedence: core `config`. */
18
+ export type ConfigLayer = {
19
+ readonly [key: string]: ConfigValue | undefined;
20
+ };
13
21
  /**
14
22
  * A site's identity, as generated into `src/config/site.generated.ts` from its `sites.json` entry.
15
23
  * Only fields a site renders from belong here; factory-only registry keys stay in `sites.json`.
@@ -31,6 +39,12 @@ export interface SiteConfig {
31
39
  twitterHandle?: string;
32
40
  };
33
41
  places: CityPlaces | WorldwidePlaces;
42
+ /** The vertical's `capabilities`; present only when it declares some. */
43
+ capabilities?: readonly string[];
44
+ /** The vertical's `defaults`, the lowest configuration layer; present only when it declares some. */
45
+ defaults?: ConfigLayer;
46
+ /** The site's own `settings` from `sites.json`, laid over `defaults`; present only when set. */
47
+ settings?: ConfigLayer;
34
48
  }
35
49
  /** A vertical manifest, `verticals/<id>/vertical.json` in the factory. Never published. */
36
50
  export interface VerticalDefinition {
@@ -45,4 +59,8 @@ export interface VerticalDefinition {
45
59
  requires: string[];
46
60
  /** Reserved for SLA-2744; empty until then. */
47
61
  routes: [];
62
+ /** The lowest configuration layer for every member site; `{}` when the vertical sets none. */
63
+ defaults: ConfigLayer;
64
+ /** Features every member site gets, as kebab-case ids; `[]` when none. */
65
+ capabilities: string[];
48
66
  }
@@ -6,4 +6,3 @@ import type { ImageMetadata } from 'astro';
6
6
  export declare function buildImageMap(mods: Record<string, {
7
7
  default: ImageMetadata;
8
8
  }>): Record<string, ImageMetadata>;
9
- export declare const keyBySlug: typeof buildImageMap;
@@ -8,4 +8,3 @@ export function buildImageMap(mods) {
8
8
  return [slug, mod.default];
9
9
  }));
10
10
  }
11
- export const keyBySlug = buildImageMap;
@@ -1,9 +1,11 @@
1
1
  export { url, publicImageUrl, normalizePagePath, toAbsoluteSiteUrl, normalizeSiteUrl } from './url.ts';
2
2
  export { getOgImagePath } from './ogImage.ts';
3
3
  export { normalizeHref, extractProseHrefs, dedupRelated } from './relatedDedup.ts';
4
- export { buildImageMap, keyBySlug } from './imageMap.ts';
4
+ export { buildImageMap } from './imageMap.ts';
5
5
  export { articleFeedItem } from './feed.ts';
6
6
  export type { FeedArticle, FeedItem } from './feed.ts';
7
7
  export { pageTypeOf } from './pageType.ts';
8
+ export { DEFAULT_ROUTES, routePath } from './routes.ts';
9
+ export type { RouteKind, SiteRoutes } from './routes.ts';
8
10
  export { outboundClassifier, outboundHostKey, applyOutboundRel } from './outbound.ts';
9
11
  export type { OutboundDomainStore } from './outbound.ts';
package/dist/url/index.js CHANGED
@@ -2,7 +2,8 @@
2
2
  export { url, publicImageUrl, normalizePagePath, toAbsoluteSiteUrl, normalizeSiteUrl } from "./url.js";
3
3
  export { getOgImagePath } from "./ogImage.js";
4
4
  export { normalizeHref, extractProseHrefs, dedupRelated } from "./relatedDedup.js";
5
- export { buildImageMap, keyBySlug } from "./imageMap.js";
5
+ export { buildImageMap } from "./imageMap.js";
6
6
  export { articleFeedItem } from "./feed.js";
7
7
  export { pageTypeOf } from "./pageType.js";
8
+ export { DEFAULT_ROUTES, routePath } from "./routes.js";
8
9
  export { outboundClassifier, outboundHostKey, applyOutboundRel } from "./outbound.js";
@@ -0,0 +1,11 @@
1
+ /** The site routes package components link to, kind → path segment. A site's `routes` prop overrides any of them. */
2
+ export declare const DEFAULT_ROUTES: {
3
+ readonly articles: "articles";
4
+ readonly articleTopic: "articles/topic";
5
+ readonly author: "author";
6
+ readonly neighborhood: "neighborhood";
7
+ };
8
+ export type RouteKind = keyof typeof DEFAULT_ROUTES;
9
+ export type SiteRoutes = Partial<Record<RouteKind, string>>;
10
+ /** `/<segment>` for `kind`, or `/<segment>/<slug>`, from `routes` first and then the default. Base path not applied. */
11
+ export declare function routePath(kind: RouteKind, slug?: string, routes?: SiteRoutes): string;
@@ -0,0 +1,12 @@
1
+ /** The site routes package components link to, kind → path segment. A site's `routes` prop overrides any of them. */
2
+ export const DEFAULT_ROUTES = {
3
+ articles: 'articles',
4
+ articleTopic: 'articles/topic',
5
+ author: 'author',
6
+ neighborhood: 'neighborhood',
7
+ };
8
+ /** `/<segment>` for `kind`, or `/<segment>/<slug>`, from `routes` first and then the default. Base path not applied. */
9
+ export function routePath(kind, slug, routes = {}) {
10
+ const segment = routes[kind] ?? DEFAULT_ROUTES[kind];
11
+ return slug === undefined ? `/${segment}` : `/${segment}/${slug}`;
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarimarcus/content-sites-core",
3
- "version": "0.31.7",
3
+ "version": "0.32.0",
4
4
  "description": "Non-visual utilities, Astro config builders and SEO schema assembly shared by the content sites.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -4,3 +4,4 @@ export type { SiteConfigOptions, SitemapRule, PagefindIntegration } from './site
4
4
  export { outboundLinkRel } from './outboundLinkRel.ts';
5
5
  export type { OutboundLinkRelOptions } from './outboundLinkRel.ts';
6
6
  export { latestGuideDate, guideDateMap, guidePublishDates } from './guideDates.ts';
7
+ export { mergeConfig, resolveConfig, siteConfigValues, hasCapability } from './precedence.ts';
@@ -0,0 +1,40 @@
1
+ import type { ConfigLayer, ConfigValue, SiteConfig } from '../types/index.ts';
2
+
3
+ const isRecord = (v: unknown): v is Record<string, ConfigValue | undefined> =>
4
+ typeof v === 'object' && v !== null && !Array.isArray(v);
5
+
6
+ /**
7
+ * `over` laid on `base`: a key `over` leaves undefined keeps the base value; an object merges key by key with the same
8
+ * rule; anything else (an array included) replaces the base value whole. Arrays never merge.
9
+ */
10
+ export function mergeConfig<T extends ConfigLayer>(base: T, over: ConfigLayer | undefined): T {
11
+ if (!over) return base;
12
+ const out: Record<string, ConfigValue | undefined> = { ...base };
13
+ for (const [key, value] of Object.entries(over)) {
14
+ if (value === undefined) continue;
15
+ const prior = out[key];
16
+ out[key] = isRecord(prior) && isRecord(value) ? mergeConfig(prior, value) : value;
17
+ }
18
+ return out as T;
19
+ }
20
+
21
+ /**
22
+ * The layers in precedence order, lowest first: the vertical's `defaults`, then the site's `settings` (both from
23
+ * `site.generated.ts`), then the props of the call. Later wins key by key; arrays are replaced, never merged.
24
+ */
25
+ export function resolveConfig<T extends ConfigLayer = ConfigLayer>(...layers: Array<ConfigLayer | undefined>): T {
26
+ return layers.reduce<ConfigLayer>((acc, layer) => mergeConfig(acc, layer), {}) as T;
27
+ }
28
+
29
+ /** A site's effective configuration: its vertical's defaults, then its own settings, then `props`. */
30
+ export function siteConfigValues<T extends ConfigLayer = ConfigLayer>(
31
+ site: Pick<SiteConfig, 'defaults' | 'settings'>,
32
+ props?: ConfigLayer,
33
+ ): T {
34
+ return resolveConfig<T>(site.defaults, site.settings, props);
35
+ }
36
+
37
+ /** Whether the site's vertical declares `capability`. */
38
+ export function hasCapability(site: Pick<SiteConfig, 'capabilities'>, capability: string): boolean {
39
+ return site.capabilities?.includes(capability) ?? false;
40
+ }
@@ -34,7 +34,7 @@ export type {
34
34
  ArticleOptions, CollectionPageOptions, ItemListOptions, AboutPageOptions, PersonOptions, AggregateOfferOptions,
35
35
  TouristDestinationFields,
36
36
  } from './pages.ts';
37
- export { hotelBuilder, activityBuilder, touristTripBuilder } from './places.ts';
38
- export type { HotelOptions, ActivityOptions, TouristTripOptions } from './places.ts';
37
+ export { hotelBuilder, activityBuilder } from './places.ts';
38
+ export type { HotelOptions, ActivityOptions } from './places.ts';
39
39
  export { eventBuilder, eventItemListBuilder } from './events.ts';
40
40
  export type { EventPolicy, EventOptions, EventItemListOptions } from './events.ts';
@@ -63,36 +63,3 @@ export function activityBuilder(options: ActivityOptions): SchemaBuilder {
63
63
  offers: offers && data.priceFrom !== undefined ? offer(data.priceFrom, currency) : undefined,
64
64
  });
65
65
  }
66
-
67
- export interface TouristTripOptions {
68
- touristType?: string;
69
- offerDescription?: string;
70
- currency?: string;
71
- }
72
-
73
- /**
74
- * A free self-guided TouristTrip at route `walk`, its stops as the itinerary.
75
- * @deprecated Tourism-only: import `touristTripBuilder` from `@sarimarcus/content-sites-tourism/schema` (SLA-2918).
76
- */
77
- export function touristTripBuilder(options: TouristTripOptions = {}): SchemaBuilder {
78
- const { touristType = 'Cultural', offerDescription = 'Self-guided walking tour — free', currency = 'EUR' } = options;
79
- return (data, ctx) => placeNode(ctx, data, 'TouristTrip', 'walk', {
80
- touristType: data.theme || touristType,
81
- offers: offer(0, currency, { description: offerDescription }),
82
- itinerary: {
83
- '@type': 'ItemList',
84
- numberOfItems: data.stops?.length || 0,
85
- itemListElement: (data.stops || []).map((stop: any, i: number) => ({
86
- '@type': 'ListItem',
87
- position: i + 1,
88
- item: {
89
- '@type': 'TouristAttraction',
90
- name: stop.name,
91
- description: stop.description,
92
- geo: geoCoordinates(stop.coordinates),
93
- ...(stop.slug && stop.type !== 'landmark' ? { url: ctx.route(stop.type, stop.slug) } : {}),
94
- },
95
- })),
96
- },
97
- });
98
- }
@@ -13,6 +13,12 @@ export type CityPlaces = {
13
13
 
14
14
  export type WorldwidePlaces = { mode: 'worldwide' };
15
15
 
16
+ /** A JSON value a vertical default or a site setting may hold. */
17
+ export type ConfigValue = string | number | boolean | null | readonly ConfigValue[] | { readonly [key: string]: ConfigValue };
18
+
19
+ /** One configuration layer: vertical `defaults`, site `settings`, or the props of a call. Precedence: core `config`. */
20
+ export type ConfigLayer = { readonly [key: string]: ConfigValue | undefined };
21
+
16
22
  /**
17
23
  * A site's identity, as generated into `src/config/site.generated.ts` from its `sites.json` entry.
18
24
  * Only fields a site renders from belong here; factory-only registry keys stay in `sites.json`.
@@ -30,6 +36,12 @@ export interface SiteConfig {
30
36
  analytics: { gtmId: string };
31
37
  social: { twitterHandle?: string };
32
38
  places: CityPlaces | WorldwidePlaces;
39
+ /** The vertical's `capabilities`; present only when it declares some. */
40
+ capabilities?: readonly string[];
41
+ /** The vertical's `defaults`, the lowest configuration layer; present only when it declares some. */
42
+ defaults?: ConfigLayer;
43
+ /** The site's own `settings` from `sites.json`, laid over `defaults`; present only when set. */
44
+ settings?: ConfigLayer;
33
45
  }
34
46
 
35
47
  /** A vertical manifest, `verticals/<id>/vertical.json` in the factory. Never published. */
@@ -45,4 +57,8 @@ export interface VerticalDefinition {
45
57
  requires: string[];
46
58
  /** Reserved for SLA-2744; empty until then. */
47
59
  routes: [];
60
+ /** The lowest configuration layer for every member site; `{}` when the vertical sets none. */
61
+ defaults: ConfigLayer;
62
+ /** Features every member site gets, as kebab-case ids; `[]` when none. */
63
+ capabilities: string[];
48
64
  }
@@ -12,5 +12,3 @@ export function buildImageMap(mods: Record<string, { default: ImageMetadata }>):
12
12
  })
13
13
  );
14
14
  }
15
-
16
- export const keyBySlug = buildImageMap;
package/src/url/index.ts CHANGED
@@ -2,9 +2,11 @@
2
2
  export { url, publicImageUrl, normalizePagePath, toAbsoluteSiteUrl, normalizeSiteUrl } from './url.ts';
3
3
  export { getOgImagePath } from './ogImage.ts';
4
4
  export { normalizeHref, extractProseHrefs, dedupRelated } from './relatedDedup.ts';
5
- export { buildImageMap, keyBySlug } from './imageMap.ts';
5
+ export { buildImageMap } from './imageMap.ts';
6
6
  export { articleFeedItem } from './feed.ts';
7
7
  export type { FeedArticle, FeedItem } from './feed.ts';
8
8
  export { pageTypeOf } from './pageType.ts';
9
+ export { DEFAULT_ROUTES, routePath } from './routes.ts';
10
+ export type { RouteKind, SiteRoutes } from './routes.ts';
9
11
  export { outboundClassifier, outboundHostKey, applyOutboundRel } from './outbound.ts';
10
12
  export type { OutboundDomainStore } from './outbound.ts';
@@ -0,0 +1,16 @@
1
+ /** The site routes package components link to, kind → path segment. A site's `routes` prop overrides any of them. */
2
+ export const DEFAULT_ROUTES = {
3
+ articles: 'articles',
4
+ articleTopic: 'articles/topic',
5
+ author: 'author',
6
+ neighborhood: 'neighborhood',
7
+ } as const;
8
+
9
+ export type RouteKind = keyof typeof DEFAULT_ROUTES;
10
+ export type SiteRoutes = Partial<Record<RouteKind, string>>;
11
+
12
+ /** `/<segment>` for `kind`, or `/<segment>/<slug>`, from `routes` first and then the default. Base path not applied. */
13
+ export function routePath(kind: RouteKind, slug?: string, routes: SiteRoutes = {}): string {
14
+ const segment = routes[kind] ?? DEFAULT_ROUTES[kind];
15
+ return slug === undefined ? `/${segment}` : `/${segment}/${slug}`;
16
+ }