Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More builtin custom replacements #7

Open
sindresorhus opened this issue Apr 29, 2018 · 14 comments
Open

More builtin custom replacements #7

sindresorhus opened this issue Apr 29, 2018 · 14 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@sindresorhus
Copy link
Owner

For popular things that makes sense. Suggestions welcome, but I'm not going to add more than maybe 30. So make it worth it.

Don't do a PR. I'll add them all at once when we've decided on what to include.

@sindresorhus sindresorhus added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Apr 29, 2018
@idleberg
Copy link

idleberg commented May 4, 2018

German umlauts (ä, ö, ü) and the letter ß (“sharp s”) are commonly replaced differently:

ä -> ae
ö -> oe
ü -> ue
ß -> ss

So maybe an option for these cases makes sense. If I'm not mistaken the ß is replaced as sz in Switzerland.

Other characters for special treament could be @ and %.

@sindresorhus
Copy link
Owner Author

So maybe an option for these cases makes sense. If I'm not mistaken the ß is replaced as sz in Switzerland.

I don't intend to internationalize this module, so the target is English.

Other characters for special treament could be @ and %.

👍

@CanRau
Copy link
Contributor

CanRau commented Jan 14, 2020

Just out of curiosity as I'm a little bit confused about slug styles in general^^
What's the reason behind not supporting i18n?
I think it's important and as shown in the example by @idleberg replacing an ä with a doesn't really make sense in the resulting word to a german user.
So again, just asking, trying to form a picture of URL slugs and reasonings behind their various possible designs 😉 😁

@sindresorhus
Copy link
Owner Author

@CanRau Unicode slugs can be fine. It really depends on your constraints, both company-wise and tech stack wise. I'm happy to add an option to preserve Unicode characters. It's just not a common request.

https://en.wikipedia.org/wiki/Clean_URL#Slug

@CanRau
Copy link
Contributor

CanRau commented Feb 1, 2020

Hum, now I'm pretty confused and I think the conversation might be confused, too 😅
I thought, for whatever reason, that slugify (this module here) replaces ä-> a but according to replacements.js#L6 it already does the right thing 😳I might've installed npm.im/slugify instead of @sindresorhus/slugify 🤣 what a shame. Now that I tried (again), that's the most likely^^

So german umlauts are properly replaced already and you don't intent to add support for the swiss variation in ß, that makes sense, if that's what you were saying. haha finally 👍

I suffered for nothing 😆 Then I believe (it seems) only #37 would be missing for @sindresorhus/slugify to be the perfect slugger for me ❤️ 🤞

@sindresorhus
Copy link
Owner Author

So german umlauts are properly replaced already and you don't intent to add support for the swiss variation in ß, that makes sense, if that's what you were saying. haha finally 👍

See my comment in #38 (comment).

@Haraldson
Copy link

Haraldson commented May 20, 2020

I think a common expectation is to have non-alphanumerical symbols map to an empty string by default. Consider for instance a business name like Daisy’s Diner – I don’t want daisy-s-diner as my slug, but rather daisys-diner.

(I half-expected each array in customReplacements to be applied directly to String.replace, but was unsuccessful in passing a regular expression as the first argument. If I could do [/\W/, ''], much would be solved.)

@sindresorhus
Copy link
Owner Author

I think a common expectation is to have non-alphanumerical symbols map to an empty string by default. Consider for instance a business name like Daisy’s Diner – I don’t want daisy-s-diner as my slug, but rather daisys-diner.

I agree with your specific example, but not that all non-alphanumerical symbols should be empty strings. Open a new issue with this and we can figure out a way to improve the output.

@deadcoder0904
Copy link

deadcoder0904 commented Aug 9, 2021

@sindresorhus What do you think about removing filler words for better SEO? See https://www.reliablesoft.net/slug/

Read https://twitter.com/deadcoder0904/status/1424627186565193734 for TL;DR

Or should this be done manually? (which makes more sense tbf)

@fannarsh
Copy link

fannarsh commented Oct 6, 2022

It would be nice to have em dash replaced by a regular -.
In many fonts there are hardly a visible difference which contributes to many copy paste "issues" from word processors.

@CanRau
Copy link
Contributor

CanRau commented Oct 8, 2022

Don't have any experience regarding em-dash though it sounds interesting 👏🏼

@fannarsh
Copy link

fannarsh commented Oct 8, 2022

My comment was actually meant for the transliterate repo, but for some reason I mixed it up 🤷
That being said, I'm assuming that this sindresorhus/transliterate#11 would take care of my suggestion.

@CanRau
Copy link
Contributor

CanRau commented Oct 9, 2022

Uh yea I see, so seems that issue got kinda forgotten

@aegatlin
Copy link
Contributor

aegatlin commented Jan 9, 2023

Regarding @Haraldson 's comment on daisy's diner becoming daisys-diner instead of daisy-s-diner, I have an open PR for that in particular, #71 , just fyi for people in this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants