Gatsby: PrismJs doesn't seem to work with Bulma

Created on 10 Oct 2018  路  3Comments  路  Source: gatsbyjs/gatsby

Description

I'm using PrismJs to highlight code that I have in some of my posts, but it doesn't seem to work well with Bulma because didn't highlight anything :/
Someone knows a workaround for this issue, or if there's any issue with my code at all that is causing this?

Steps to reproduce

Demo, so you can see it working.
Source Code

Expected result

Highlight the code that is written inside markdown pages with Bulma css.

All 3 comments

@SamuelPinho you had some issues with your gatsby-config.js, specifically with nesting options in the wrong place, or in the wrong plugin.

You'll want something like this:

module.exports = {
  siteMetadata: {
    title: 'Samuel Monteiro',
    links: {
      github: 'https://github.com/SamuelPinho',
      linkedin: 'https://www.linkedin.com/in/samuelmpinho/',
      medium: 'https://medium.com/@samuelmonteiro',
    },
  },
  pathPrefix: "/blog",
  plugins: [
    'gatsby-plugin-sass',
    'gatsby-plugin-react-helmet',
    {
    resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: 'gatsby-remark-prismjs',
            options: {
              classPrefix: "language-",
              showLineNumbers: true,
            }
          }
        ],
      },
    },
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: 'gatsby-starter-default',
        short_name: 'starter',
        start_url: '/',
        background_color: '#663399',
        theme_color: '#663399',
        display: 'minimal-ui',
        icon: 'src/images/gatsby-icon.png', // This path is relative to the root of the site.
      }
    },
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        name: 'src',
        path: `${__dirname}/src/blog/`,
      }
    },
    'gatsby-plugin-offline',
  ],
}

Note: there are still some issues with bulma (i.e. numbers are far too large) but that's because bulma is targeting the number selector, which is causing the issues. You'll probably need to override in src/templates/blog-post.js to apply some custom CSS to reset that global style!

screen shot 2018-10-10 at 8 53 37 am

screen shot 2018-10-10 at 8 54 09 am

Thanks @DSchau, this change even made other things works as expected too. :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

magicly picture magicly  路  3Comments

jimfilippou picture jimfilippou  路  3Comments

signalwerk picture signalwerk  路  3Comments

rossPatton picture rossPatton  路  3Comments

timbrandin picture timbrandin  路  3Comments