-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Links in Code Examples (via magic comments) #7170
Comments
Sounds cool to me! To be clear, we won't make this the default behavior, because I don't feel like this will be used by a lot of users; this requires having some ad-hoc Markdown parser on client-side, so the effort is non-trivial and probably means bundle size bloat. However, we will make the magic comment system extensible (which it currently isn't) so you can more easily build this in userland through swizzling |
I plan to refactor CodeBlock already so this will become even simpler: swizzle Was wondering: do we have an need for this in our own doc? We could add it to dogfood and improve our doc DX, just need to figure a few good places to use this. |
Oh... I just realized this will not be a normal magic comment either! Because the definition of a "magic comment" is something that adds metadata about the next line (e.g. |
Now that #7175 is merged, this should be able to be implemented in userland. |
Thank you @Josh-Cena |
Have you read the Contributing Guidelines on issues?
Description
Clickable links in code samples. The Firebase documentation uses a similar system for linking code snippets to configuration information: https://firebase.google.com/docs/web/setup#add-sdks-initialize
Example:
The bottom of this section of the doc mentions that the magic comment system could extend in the future for additional markup use cases. I believe this is one potential use case for an extension of that system.
Has this been requested on Canny?
No response
Motivation
In many cases, it makes more sense to surface links through prose or an admonition before or after a code block. But sometimes this:
API design
I'm not super familiar with the implementation for the magic comment system. But right now, that system uses the following syntax for highlights:
I imagine we could extend these magic comments to use an uncommon keyword for linking to a docusaurus ID, with a link name and reference as arguments provided in the markdown format:
Have you tried building it?
no
Self-service
The text was updated successfully, but these errors were encountered: