Implement a importable Sanitize (Slugify) Function #32926
Unanswered
nico-k3
asked this question in
Ideas / Feature Requests
Replies: 1 comment 3 replies
-
Having the same issue mentioned here #32820 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Guys!
Sometimes it can be tricky to source data from a Backend and create pages with let's say the title. Content creators are usually not familiar with things that can go wrong and tend to use some patterns that give headaches to us. They use emojis, brackets, slashes, etc.
Fortunately, there are some helpers like slugify or @sindresorhus/slugify to get rid of the nasty stuff and create clean versions of the input String. Unfortunately, though they are not made for Gatsby and Gatsby itself has some special behaviors.
As an example: when today one of the editors published an article with a title like "This // is nice", Gatsby interpreted it as a subpage and therefore created the page "/articles/this/is-nice" - certainly not a big deal but my slugify solution just erased the slashes from the title and therefore a dead link was published to the page.
Also of course if the Gatsby Team ever decides to change something about their algorithm we all would have to adjust. As Gatsby itself seems to have a solution it uses to sanitize Strings and make them URL ready - wouldn't it be nice if we could just use the same algorithm?
How would you like this feature? A simple importable slugify function inside of the Gatsby core to get rid of the headaches.
Nico
Beta Was this translation helpful? Give feedback.
All reactions