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

Omit anchors for headers in feed? #4124

Closed
Daniel15 opened this issue Jun 14, 2015 · 4 comments
Closed

Omit anchors for headers in feed? #4124

Daniel15 opened this issue Jun 14, 2015 · 4 comments

Comments

@Daniel15
Copy link
Member

The RSS feed (http://facebook.github.io/react/feed.xml) has anchors and "#" links after headings:

<a class="anchor" name="migrating-to-babel"></a>Migrating to Babel <a class="hash-link" href="#migrating-to-babel">#</a>

This looks kinda ugly in feed readers, and doesn't really serve a purpose:
screen shot 2015-06-14 at 11 55 35 am

Most feed readers modify links so they're relative to the feed URL, so these links are actually becoming http://facebook.github.io/react/feed.xml#migrating-to-babel which doesn't do anything useful.

Can we remove these from the feed?

@zpao
Copy link
Member

zpao commented Jun 15, 2015

Not super easily right now since that's baked into the markdown processing (https://github.com/facebook/react/blob/master/docs/_plugins/header_links.rb)

@bryanbraun
Copy link
Contributor

One option is to render them clientside, using a utility like AnchorJS. Anchors wouldn't appear in RSS since the feed content would leave the JS behind. It looks like all the same IDs would be generated, (it uses similar regex code to convert the titles to lowercase hyphen-delimited words).

Let me know if you're interested in that approach and I'll put together a pull request.

@sophiebits
Copy link
Collaborator

@bryanbraun Seems reasonable, though let's just inline the logic instead of pulling in a third-party library (and let's make sure the regex is equivalent in order to preserve existing links). Should only be a few lines of JS.

@bryanbraun
Copy link
Contributor

See the approach at #4165. It uses the same regex patterns, so the links are backwards compatible.

lacker pushed a commit that referenced this issue Mar 1, 2017
…4165)

* Replace the header_links plugin with client-side generated anchors.

Fixes #4124

* Move anchor-link code into a separate script

Also adds a couple comments, for context.
gaearon pushed a commit that referenced this issue Mar 9, 2017
…4165)

* Replace the header_links plugin with client-side generated anchors.

Fixes #4124

* Move anchor-link code into a separate script

Also adds a couple comments, for context.

(cherry picked from commit 7a878d2)
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

No branches or pull requests

4 participants