-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Description
Can multi-language support code blocks, support anchors which allow the anchored code block to open?
For example, I would like to be able to offer a user a link, either via the docusaurus side bar, or directly, that allows them to jump to a language specific block.
EG clicking Java https://docusaurus-five-rho.vercel.app/docs/markdown-features/code-blocks#java would navigate to that part of the page and make that tab visible.
- The anchor link from the side bar will only work if the anchor is visible
- Hotlinking via the full url plus anchor if in a code block, will not move to the code block even if the anchor is in a visible tab.
This might just be a limitation of my HTML scripting foo, as is possible, if so, please show me the way!
Has this been requested on Canny?
No response
Motivation
we support an open source project which has a significant feature set across multiple language implementations.
I would like to be able to connect this up with syncing tab choices as it would enable readers to ensure they only see information that is relevant to them, in their preferred programming language.
API design
No response
Have you tried building it?
Yes,
See example from docusaurus master, only addition is https://github.com/YOU54F/docusaurus/commit/0e297b966a34e68c4d612a42b1ad3f634d923395 to insert anchors on each of the code block tabs.
Deployed here via vercel however the headers aren't showing
https://docusaurus-you54f.vercel.app/docs/markdown-features/code-blocks
You can clone my master branch g clone git@github.com:YOU54F/docusaurus.git
npm install && cd website && npm start
Headers added and visible locally
clicking from TOC will anchor to Javascript tab
If java tab is pre selected and therefore visible
clicking from TOC will anchor to Java tab
Hot linking to any of the code block anchors
http://localhost:3000/docs/markdown-features/code-blocks#javascript even the visible javascript one will take the user to the top of the page.
Self-service
- I'd be willing to contribute this feature to Docusaurus myself.