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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add generated id to markdown headings (#833) #1163

Merged
merged 1 commit into from Oct 8, 2018
Merged

Feat: Add generated id to markdown headings (#833) #1163

merged 1 commit into from Oct 8, 2018

Conversation

wkillerud
Copy link
Contributor

This PR introduces preliminary support for linking to headings
within an example text using markdown headings.

Since linking in this way requires using the # character it means you
can't link to a section in isolated mode (for instance to
http://localhost:6060/#!/WrappedButton#example-section) on account of
the #! being reserved for routing.

It may still be useful to the reporter of #833 for linking to a section in the list
view, and may act as a base for further improvements 馃檪

@wkillerud
Copy link
Contributor Author

I don't know the inner workings of the RSG router, but if it's possible to rewrite (long term goal for sure) to free the # character using the HTML5 History API it would make this feature much more useful.

Still, even with its limitations this version may add some value :)

@codecov-io
Copy link

codecov-io commented Oct 5, 2018

Codecov Report

Merging #1163 into next will not change coverage.
The diff coverage is 100%.

Impacted Files Coverage 螖
...arkdown/MarkdownHeading/MarkdownHeadingRenderer.js 100% <100%> (酶) 猬嗭笍

Copy link
Member

@sapegin sapegin left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

We can't use HTML5 History API because it will break external links to Styleguidist and page refresh.

markdown-to-jsx already passes an ID, so we can use it instead of generating our own:

https://github.com/probablyup/markdown-to-jsx/blob/56c99dd95f990e266fca52278f5b394d24fdc6f6/index.js#L998-L1016

This commit introduces preliminary support for linking to headings
within an example text using markdown headings.

Since linking in this way requires using the # character it means you
can't link to a section in isolated mode (for instance to
http://localhost:6060/#!/WrappedButton#example-section) on account of
the #! being reserved for routing.
@wkillerud
Copy link
Contributor Author

markdown-to-jsx already passes an ID, so we can use it instead of generating our own

Allright, didn't know that - nice 馃憤 Made the requested changes and removed the stuff that became redundant.

@sapegin sapegin merged commit 82f22d2 into styleguidist:next Oct 8, 2018
@sapegin
Copy link
Member

sapegin commented Oct 8, 2018

Thanks, merged!

@wkillerud wkillerud deleted the feat/heading-anchor-ids branch October 9, 2018 06:17
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.

None yet

3 participants