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

Make headlines permalink-able #1004

Closed
peterbe opened this issue Jul 31, 2020 · 5 comments · Fixed by #1061 or #1065
Closed

Make headlines permalink-able #1004

peterbe opened this issue Jul 31, 2020 · 5 comments · Fixed by #1061 or #1065

Comments

@peterbe
Copy link
Contributor

peterbe commented Jul 31, 2020

Let's do whatever it takes to make it performant, non-obtrusive, intuitive, and accessible to link to headings.
In today's master the only way you can make a link to a heading is if you scroll up and find the TOC in the sidebar (on mobile it's much more hidden).

Note! I think we should still keep the TOC tables in the sidebar.

There are two potential ways to do permalink-able headings. The way npmjs.com and github.com does READMES
that there's a little "chain icon" that appears to the left (or to the right) when you hover over the link.
Screen Shot 2020-07-31 at 7 27 32 AM

Another approach is to simply turn every heading into a "self-link" like docs.github.com does.
Example page
The headings are basically like this:

<h3 id="enabling-github-dependabot-version-updates-for-actions">
  <a href="#enabling-github-dependabot-version-updates-for-actions">
    Enabling GitHub Dependabot version updates for actions</a></h3>

The advantages of that are that it requires 0 CSS and 0 JS to make it happen, and it works without a mouse device.

@peterbe
Copy link
Contributor Author

peterbe commented Jul 31, 2020

I definitely favor the way docs.github.com does it and I'm confident it can be done pretty easily with Yari since we control the HTML as a DOM (with cheerio).

I think it's up to @schalkneethling and @malqinneh to decide and perhaps they prefer to push this out to the design system process.

But it might be worth it for the dev team (hi @escattone and @Gregoor ) to consider throwing this in now as an HTML thing and then mdn-minimalist can style it.

What do you think?

@peterbe
Copy link
Contributor Author

peterbe commented Jul 31, 2020

Whatever we build, let's not build a thing that requires some client-side JavaScript to mutate the DOM based on some query selectors.

@peterbe
Copy link
Contributor Author

peterbe commented Aug 12, 2020

@escattone What would it take to write a piece of cheerio mutation that turns <h2 id="text_and_stuff">Text & Stuff</h2> into <h2 id="text_and_stuff"><a href="#text_and_stuff">Text & Stuff</a></h2>?
I know it's possible and not hard to do with cheerio but I'm not familiar with the repercussions with live samples.

@escattone
Copy link
Contributor

@peterbe 👍 We could definitely do that without any repercussion to the live samples.

peterbe added a commit to peterbe/yari that referenced this issue Aug 12, 2020
peterbe added a commit that referenced this issue Aug 13, 2020
* Make headlines permalink-able

Fixes #1004

* Update client/src/document/ingredients/prose.tsx

Co-authored-by: Schalk Neethling <[email protected]>

Co-authored-by: Schalk Neethling <[email protected]>
@peterbe
Copy link
Contributor Author

peterbe commented Aug 13, 2020

Oops. Typo in the string interpolation in 0b47590

@peterbe peterbe reopened this Aug 13, 2020
peterbe added a commit to peterbe/yari that referenced this issue Aug 13, 2020
peterbe added a commit that referenced this issue Aug 13, 2020
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 a pull request may close this issue.

2 participants