-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
New gatsby-remark-embed-snippet plug-in #3012
New gatsby-remark-embed-snippet plug-in #3012
Conversation
I kind of hate that "Strings must use backtick quotes" lint rule 😁 |
Deploy preview failed. Built with commit bded111 https://app.netlify.com/sites/using-glamor/deploys/5a17652ba1147749ece5b65f |
Deploy preview ready! Built with commit 91d0d73 |
Deploy preview ready! Built with commit 91d0d73 |
Deploy preview failed. Built with commit aad2f3b https://app.netlify.com/sites/using-glamor/deploys/5a185c4aa114770604e5b6e7 |
Done. The plug-in now supports |
I left a note about possible follow-up work on the PR. If you're interested in merging that, let me know and I'll be happy to submit another PR. If you're not interested, that's okay too. Let me know and I'll just roll my own plug-in for use in reactjs.org 😄 |
This is the best rule ever :-D |
const visit = require(`unist-util-visit`) | ||
|
||
// HACK: It would be nice to find a better way to share this utility code. | ||
const highlightCode = require(`gatsby-remark-prismjs/highlight-code`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What we've been doing is to just split it out into a new plugin.
100% agree! It's super obnoxious haha :-) Inline highlight comments are way better. And yeah, allowing code re-use is always very nice too. If this is ready to go, I'll merge/publish and wait looking forward to your follow-up PR :-) |
This should be ready to go, yes. I've got a branch of the reactjs.org docs built using this plug-in just to test it out. 😄 I'll send a follow-up PR sometime this week. |
|
Yup it's a global. It's also used here (although that's my fault too I guess 😁 ) |
Huh, weird the other place doesn't fail the lint too. |
…by into gatsby-remark-embed-snippet
Agreed! I'll add an entry to the ESLint config though. |
I believe it should be good to go now. |
Cool! This is awesome stuff, looking forward to seeing it rolled out on reactjs.org! |
For a more detailed explanation of this plug-in and its options, refer to the README.
Given a file like this (eg
examples/hello-world.js
):And a markdown snippet like this:
Create HTML like this:
This PR is related to ReactJS.org issue reactjs/react.dev/issues/310 and PR reactjs/react.dev/pull/331
Follow-up Work
I think the highlight marker comments from this PR would be a nice addition to the
gatsby-remark-prismjs
plugin as well. Defining ranges at the top of the markdown comment is kind of painful, especially for larger blocks or edits. Ideally this plug-in could be simplified to just read files from disk and pass their contents along to a method shared with that plug-in to convert to Prism blocks.I'd be willing to make this refactor as a follow-up PR if you'd be interested?