Every provider lived at /coach/<pubkey>/<id> regardless of craft (a barber got a "coach" URL). New src/lib/labRoutes.ts maps craft kind → segment and builds the canonical path; the router adds /lab/:craft/:pubkey/:identifier (the craft segment is cosmetic — the page still resolves by pubkey + identifier) and keeps /coach/... working for old links. All generated links updated: offer-form redirects, Lab cards + "Your Lab profiles", cross-links, spot/event/admin links, the CVM client URL, the share path, and the SPA clean-link shim.
39 lines
1.6 KiB
TypeScript
39 lines
1.6 KiB
TypeScript
import {
|
|
SKATE_COACH_KIND, SKATE_FILMER_KIND, SKATE_EDITOR_KIND, SKATE_PHOTOGRAPHER_KIND,
|
|
SKATE_BUILDER_KIND, SKATE_ARTIST_KIND, SKATE_GRAFFITI_KIND, SKATE_TATTOO_KIND,
|
|
SKATE_TRAINER_KIND, SKATE_MUSICIAN_KIND, SKATE_JUDGE_KIND, SKATE_ORGANIZER_KIND,
|
|
SKATE_BARBER_KIND,
|
|
} from '@/lib/types';
|
|
|
|
/** Lab craft kind → canonical URL segment (matches `becomeRoles` slugs). */
|
|
export const LAB_TYPE_BY_KIND: Record<number, string> = {
|
|
[SKATE_COACH_KIND]: 'coach',
|
|
[SKATE_FILMER_KIND]: 'filmer',
|
|
[SKATE_EDITOR_KIND]: 'editor',
|
|
[SKATE_PHOTOGRAPHER_KIND]: 'photographer',
|
|
[SKATE_BUILDER_KIND]: 'builder',
|
|
[SKATE_ARTIST_KIND]: 'artist',
|
|
[SKATE_GRAFFITI_KIND]: 'graffiti',
|
|
[SKATE_TATTOO_KIND]: 'tattoo',
|
|
[SKATE_TRAINER_KIND]: 'trainer',
|
|
[SKATE_MUSICIAN_KIND]: 'musician',
|
|
[SKATE_JUDGE_KIND]: 'judge',
|
|
[SKATE_ORGANIZER_KIND]: 'organizer',
|
|
[SKATE_BARBER_KIND]: 'barber',
|
|
};
|
|
|
|
/**
|
|
* Canonical path for a Lab provider profile: `/lab/<craft>/<pubkey>/<identifier>`.
|
|
*
|
|
* The craft segment is cosmetic (the detail page resolves by pubkey + identifier
|
|
* across all kinds) but gives each craft a meaningful, shareable URL instead of
|
|
* every provider living under `/coach/…`.
|
|
*/
|
|
export function labProfilePath(profileType: string, pubkey: string, identifier: string): string {
|
|
return `/lab/${profileType}/${pubkey}/${identifier}`;
|
|
}
|
|
|
|
/** Same as {@link labProfilePath} but from a kind number (e.g. a coord). */
|
|
export function labProfilePathFromKind(kind: number, pubkey: string, identifier: string): string {
|
|
return labProfilePath(LAB_TYPE_BY_KIND[kind] ?? 'coach', pubkey, identifier);
|
|
}
|