requireSlug()function
requireSlug(str: string, caller: AnyCaller = requireSlug): string
| Param | Type | |
|---|---|---|
str | string | The string to convert. required |
caller | AnyCaller | 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"