gatsby-starter-ghost icon indicating copy to clipboard operation
gatsby-starter-ghost copied to clipboard

Prism.js plugin

Open aileen opened this issue 6 years ago • 3 comments

Problem description

Prism.js doesn't work "out of the box" for Ghost posts currently. There is a workaround to use Prism.js, which is used in the Ghost Docs repository here:

class Post extends React.Component {
    componentDidMount() {
        Prism.highlightAll()
    }
   ...
}

This solution only supports basic languages, which handlebars, yaml, and json for example are not being considered as.

Proposal

Similar to the gatsby-remark-prismjs plugin, we can create a plugin for Ghost that does the same for Ghost posts.

Maybe there are other solutions for this. This needs to be investigated further.

Todos

  • [ ] investigate do-ability further
  • [ ] write up tech spec and agree on solution with core team
  • [ ] implement solution
  • [ ] publish plugin

aileen avatar Jan 14 '19 06:01 aileen

What about installing babel-preset-gatsby and babel-plugin-prismjs and creating a custom .babelrc file which specifies used languages:

{
  "presets": [
    [
      "babel-preset-gatsby"
    ]
  ],
  "plugins": [
    [
      "prismjs",
      {
        "languages": [
          "javascript",
          "css",
          "markup",
          "json",
          "handlebars",
          "yaml"
        ],
        "theme": "okaidia",
        "css": true
      }
    ]
  ]
}

nehalist avatar Apr 06 '19 17:04 nehalist

Thanks @nehalist ❤️

This absolutely works for now! Will add this to the starter soon 👍

aileen avatar Apr 11 '19 08:04 aileen

Any news on this ?

ScreamZ avatar May 13 '19 11:05 ScreamZ