Open sergeysova opened 4 years ago
Or, it can be implemented like this https://stackoverflow.com/questions/59098769/how-to-render-a-react-component-styled-with-emotion-in-an-iframe-in-gatsby-site
For example: https://codesandbox.io/s/b7e7c
How to transform: https://youtu.be/ALspNtrOqDk
It is required to create an encapsulated page to test component media-queries.
Steps how it can be implemented:
./gatsby-theme-woly/plugins/gatsby-plugin.js
import
nodes of pagejsx
nodeimport
nodes to a new page withjsx
node (maybe it can be created withcreateNode
andcreatePage
API inactions
, look atgatsby-source-filesystem
)jsx
node to an iframe with a link to a created page (node typehtml
)Source
src/components/button/usage.mdx
file:Expected output:
Expected output for example 1:
Expected output for example 2:
How to visit import nodes and collect it:
What is collected in
imports
:gatsby-theme-woly/plugins/remark-plugin.js
This plugin creates a copy of the
jsx
node ascode
node, to show the source of the markdown.For example source
.mdx
file:Gatsby creates live button from that
mdx
node. Remark plugin addscode
block to show source below:Rehype plugin is a transformer for converting markdown AST to HTML AST