-
Notifications
You must be signed in to change notification settings - Fork 60k
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
A quick experiment to get allow React components in Markdown pages and throughout the site #610
Conversation
ca491da
to
71ffb35
Compare
@JasonEtco would you be down to 🍐 on this at some point? server side rendering is working but I need some help with the webpack and logic to get the react components hydrated client side. |
Thinking we need to do something like this (pseudocode) at the bottom of every component in This should make sure that when in the browser every component gets hydrated
And then part two would be figuring out how to get the react files that work on the server working in the browser. Assuming webpack would be needed for that . |
Did the first part of what I think I will work here: 4d9a6c7 Next need to figure out webpack |
Got it working! |
26ec0bd
to
83a81e7
Compare
Also added fronmatter for interactive: true to turn on React on a file by file basis and prevent slowing down the builds for non-react files
12cecee
to
b781e43
Compare
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.
@chiedo This is really cool! The examples work nicely. ⚡
I did a quick review (since this is still in progress) and left a few early thoughts. I didn't dig into any of the Babel stuff.
One note: this adds a lot of dependencies to the docs app. I wonder if we can shift any of that dependency burden to Primer React components?
content/github/getting-started-with-github/access-permissions-on-github.md
Outdated
Show resolved
Hide resolved
react/CodeBlock.js
Outdated
@@ -0,0 +1,81 @@ | |||
const React = require('react') | |||
const ReactDOM = require('react-dom') | |||
const { Prism } = require('react-syntax-highlighter') |
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.
We use http://ghub.io/rehype-highlight (via docs/render-content
via hubdown) for syntax highlighting everywhere else. If we use Prism here, we're probably going to get different highlighting?
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.
Yeah we could! My work was solely to do a proof of concept to make sure we could do whatever we want. I'm not actually recommended the use of any of these specific react components. Just making sure we can render any react component and have it be functional.
react/CodeBlock.js
Outdated
const ReactDOM = require('react-dom') | ||
const { Prism } = require('react-syntax-highlighter') | ||
const { dark } = require('react-syntax-highlighter/dist/cjs/styles/prism') | ||
const { Tab, Tabs, TabList, TabPanel } = require('react-tabs') |
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.
Can we use the Primer component here instead? https://primer.style/components/TabNav
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.
Same answer as #610 (comment)
This is an experiment to get React components working in markdown pages. Super rough and a proof of concept.
With the goal being to make our codebase more extensible by giving us access to the entire React ecosystem.
Read about how it works here
Todos
Todos if we move forward with this experiment
Worth considering in the future
Check off the following: