label

label(string) turns a slug into a human-friendly label: it replaces every - and _ with a space, then collapses runs of whitespace into a single space. Useful for deriving a readable heading from a route segment or a key.

Part of pota/use/string. For kebab-case → camelCase see dashesToCamelCase.

Arguments

Argument Type Description
string string The slug to humanize.

Returns: string — the slug with separators turned into spaces.

Examples

Slug to heading

Labels a route segment for display.

import { label } from 'pota/use/string'

label('my-cool_page') // 'my cool page'
label('hello___world') // 'hello world'