get html from remark node in on create node #34183
-
|
👋 I'm working on migrating some content from being externally parsed to internally parsed by gatsby. On plugins.jenkins.io I have asciidoc, markdown, and straight up HTML. I really loved how easy it was to integrate with gatsby-transform-remark, and I've gotten gatsby-transform-rehype working pretty nicely (gotta submit some patches upstream). I now want to get markdown content to go through rehype, so I can share plugin logic. I've run into a problem though, since node.html is only generated when you request the data via graphql (setFieldsOnGraphQLNodeType) I can't take markdown => remark => HTML => rehype => plugins. Is there any way for me to get access to remakr's HTML from oncreatenode/setFieldsOnGraphQLNodeType that transform-rehype uses so I can stack the transformers? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
|
Not directly. Markdown -> HTML is done lazily as it's CPU intensive. That you can't do this is definitely a weakness of the design of the transformer atm. Perhaps there could be a new option added to transformer-remark to create a new HTML node that's a child of the markdown node so you'd have |
Beta Was this translation helpful? Give feedback.
-
|
Okay awesome. I'm not crazy. I started to put console logs everywhere to try and find it. I was hoping there was a way to call graphql query from either function as a work around I'm learning a lot about the internals of gastby but not quite ready to suggest fundimental changes to such a popular plugin. |
Beta Was this translation helpful? Give feedback.
-
|
@KyleAMathews drat and because its a resolver and not a createFieldExtension I can't stack it right? (I was thinking of in theory getHtml which calls getHtmlAst could be extended to take a list of rehype-transforms plugins as they are both just operating on the hast? |
Beta Was this translation helpful? Give feedback.
-
|
I would like to be a part of a "rethink" of how markdown and ecosystem is used within Gatsby if a there is to be a task force of some kind... |
Beta Was this translation helpful? Give feedback.
Not directly. Markdown -> HTML is done lazily as it's CPU intensive. That you can't do this is definitely a weakness of the design of the transformer atm. Perhaps there could be a new option added to transformer-remark to create a new HTML node that's a child of the markdown node so you'd have
markdown node -> MarkdownRemark -> MarkdownRehype(or whatever would make sense on the last one) 🤔