Created
October 2, 2023 13:42
-
-
Save stekhn/ce0a0f7fc258523800cf33b1f7ea44a9 to your computer and use it in GitHub Desktop.
Convert a string like a headline to a slug than can be used in a URL. German umlauts get transcribed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const slugify = (string) => | |
string | |
.trim() | |
.toLowerCase() | |
.replace(/\s+/g, "-") | |
.replace(/ä/g, "ae") | |
.replace(/ö/g, "oe") | |
.replace(/ü/g, "ue") | |
.replace(/\u00df/g, "ss") | |
.replace(/[^a-z0-9-]/g, ""); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment