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

fix(gatsby-remark-autolink-headers): remove accents from anchors #11575

Merged
merged 2 commits into from
Feb 27, 2019

Conversation

windkomo
Copy link
Contributor

@windkomo windkomo commented Feb 5, 2019

Removing accent characters from URLs (and thus anchors links) seems preferable to me.
What do you guys think?

@pieh
Copy link
Contributor

pieh commented Feb 5, 2019

This is potentially breaking change (links would potentially change). It's not a blocker - just documenting that we would need bump major version for this change.

I feel like change like this warrant adding some tests to cover cases of headings with accent characters to make sure we don't introduce regressions later on.

@pieh pieh added the breaking change If implemented, this proposed work would break functionality for older versions of Gatsby label Feb 5, 2019
@pieh
Copy link
Contributor

pieh commented Feb 5, 2019

I'm not sure on this, but are accented characters invalid as element IDs / link targets? If it's not invalid maybe instead of breaking change we could add plugin option to convert to latin (or whatever @sindresorhus/slugify does)?

@pieh
Copy link
Contributor

pieh commented Feb 5, 2019

So did some code reading and it seems we can add option to optionally use https://lodash.com/docs/4.17.11#deburr to remove accents

@windkomo
Copy link
Contributor Author

windkomo commented Feb 5, 2019

@pieh thanks for taking a look!
Accented characters are not invalid in URLs, but to me they are likely to cause issues like encoding.
Slugifying strings should always remove diacritics to avoid any kind of encoding issue so I was very surprised to see accented characters in my address bar 😄
Accented characters makes it harder to type URLs too, if you don't put the right char then it will 404.

@windkomo
Copy link
Contributor Author

windkomo commented Feb 6, 2019

@pieh I think your solution to keep the github slugger thing, and optionally use lodash deburr to remove accents is good. I still think removing accents should be the default behavior, what do you think about introducing this as a feature for now and as a breaking change if we want to later?

@pieh
Copy link
Contributor

pieh commented Feb 6, 2019

what do you think about introducing this as a feature for now and as a breaking change if we want to later?

This sounds perfect to me! We just don't have enough data to make informed decision for all the people, but at least providing option would unblock people that definitely want this behaviour.

@windkomo windkomo force-pushed the anchor-accents branch 2 times, most recently from bf37cc1 to 6b17c9c Compare February 11, 2019 15:52
@windkomo
Copy link
Contributor Author

@pieh I made some changes, let me know if there's anything wrong!

Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I love that removeAccents is optional.

@wardpeet wardpeet added status: awaiting author response Additional information has been requested from the author and removed breaking change If implemented, this proposed work would break functionality for older versions of Gatsby status: awaiting author response Additional information has been requested from the author labels Feb 27, 2019
@wardpeet wardpeet merged commit b6b3045 into gatsbyjs:master Feb 27, 2019
@gatsbot
Copy link

gatsbot bot commented Feb 27, 2019

Holy buckets, @windkomo — we just merged your PR to Gatsby! 💪💜

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. (Currently we’ve got a couple t-shirts available, plus some socks that are really razzing our berries right now.)
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants