requireSlug()function

requireSlug(str: string, caller: AnyCaller = requireSlug): string
ParamType
strstring
The string to convert. required
callerAnyCaller
Function to attribute a thrown error to (defaults to requireSlug itself). Defaults to requireSlug
Return
string
The kebab-case slug.
Throws
RequiredError
If conversion resulted in an empty string.

Convert a string to a kebab-case URL slug, or throw RequiredError if conversion resulted in an empty ref.

Examples

requireSlug("Hello World!") // "hello-world"