gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

Prism JS not running when compiling Markdown manually (I think) #4988

Closed crittermike closed 6 years ago

crittermike commented 6 years ago

Description

PrismJS doesn't seem to be getting added to my page. I added the theme and the CSS for that is there, but the JS itself doesn't exist so none of the highlighting happens.

I think it may be because I followed this guide which tells me to compile the markdown like so:

<div dangerouslySetInnerHTML={{
        __html: unified()
            .use(markdown)
            .use(html)
            .processSync(post.Body)
    }}
/>

Maybe doing it that way prevents remark from adding Prism to the page?

Steps to reproduce

You could clone this repo and run npm install then gatsby develop and then visit http://localhost:8000/ramblings/exporting-importing-large-drupal-databases if necessary, I suppose.

Expected result

Prism should be highlighting code blocks.

Actual result

Code blocks just get displayed as regular old <pre> tags.

Environment

File contents (if changed):

All of these are available at the repo posted above, if needed

gatsby-config.js: package.json: gatsby-node.js: gatsby-browser.js: gatsby-ssr.js:

crittermike commented 6 years ago

Looks like the actual fix is to make the Airtable source plugin allow for something like this: https://www.gatsbyjs.org/packages/gatsby-source-mongodb/?=mongo#mapping-mediatype-feature

Yeah?

KyleAMathews commented 6 years ago

Have you looked at using https://www.gatsbyjs.org/packages/gatsby-remark-prismjs/?=prismjs

KyleAMathews commented 6 years ago

Ah yeah! Adding mapping like that would be ideal as then gatsby-remark-prismjs would just work.

crittermike commented 6 years ago

@KyleAMathews yes I believe I've followed all of the directions on that page. I think the question is basically just "how can I make remark plugins run on my content if I'm transforming markdown to HTML manually"? But yeah, just fixing the Airtable plugin seems like it would solve this.

KyleAMathews commented 6 years ago

Due to the high volume of issues, we're closing out older ones without recent activity. Please open a new issue if you need help!

crittermike commented 6 years ago

https://github.com/jbolda/gatsby-source-airtable/ supports this now for anyone using Airtable.