| name | slugify |
| description | Converts a title or heading into a URL-safe slug (lowercase, hyphen-separated). Use when generating a filename, anchor link, or URL path segment from a title. |
| category | dev |
slugify
Converts an input string into a clean, URL-safe slug.
Steps
- Lowercase the entire input string.
- Replace whitespace with hyphens.
- Remove any character that isn't a lowercase letter, digit, hyphen, or apostrophe.
- Collapse multiple consecutive hyphens into a single hyphen.
- Trim any leading or trailing hyphens.
- Return the resulting slug.
Gotchas
- Numbers are kept as-is (e.g. "Top 10 Tips" → "top-10-tips").
- Punctuation like colons, commas, and question marks is simply dropped, not replaced with a hyphen.