Skip to content

toRouteSegmentPreserveCase

Slugify a path segment (type name) for a URL/route while PRESERVING case: collapse runs of non-alphanumeric characters to - and trim. Used for the case-preserved slug: frontmatter and the internal links that point at it, so URLs read as pretty PascalCase (e.g. /api/.../TypeName/).

Import:

import { toRouteSegmentPreserveCase } from '@mnaoumov/typescript-dev-toolkit/docs-site/api-doc-route-segments';

Signature:

function toRouteSegmentPreserveCase(segment: string): string

Parameters:

Parameter Type Description
segment string The segment.

Returns: string — The slug, or unnamed when nothing alphanumeric is left.


Links to this page: