Docz: Remark plugins are not working

Created on 22 Oct 2019  ·  11Comments  ·  Source: doczjs/docz

Bug Report

Describe the bug

When I am trying to specify mdPlugins in doczrc.js, I get an error while building app:

UNHANDLED REJECTION Cannot read property 'type' of null

To Reproduce

Just try to add some plugin for remark to doczrc.js

import breaks from 'remark-breaks';

export default {
  // ...
  mdPlugins: [breaks],
};

It seems like invalid options generation for gatsby-theme-docz plugin in .docz/gatsby-config.js, where mdPlugins: [null]

Environment

  • docz version: 2.0.0-rc.58
  • OS: OSX 10.15
  • Node/npm version: 12.11.1/6.7.0
stale

Most helpful comment

It is a bit shame that example from the official documentation page does not work :/ I just started using it...

All 11 comments

Hey, this is still an issue, following https://www.docz.site/docs/mdx-plugins does not work because of this.

Does somebody know the reasons for this / is there a workaround?

Could you look at the gatsby-remark-vscode plugin example : https://github.com/doczjs/docz/blob/master/examples/with-gatsby-remark-vscode/

They are defined as gatsbyRemarkPlugins in doczrc.js

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@rakannimer this is not entirely correct, because AFAICT there is a difference between "gatsby package" remark plugins and standalone ones.

While the former ones work fine, the latter ones don't. And as it seems that there is not a gatsby plugin for every standalone one, this is indeed an issue

➕ 1️⃣

Yeah, this is a separate issue.

It is a bit shame that example from the official documentation page does not work :/ I just started using it...

I believe the issue is related to the issue I filed: #1430. Docz does a JSON.stringify to write the Gatsby configuration to disk. A function like the imported plugin won't get transferred correctly.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This seems not resolved, so not stale

If you are using gatsby-theme-docz with a doczrc.js, a potential workaround is to place the plugin config in gatsby-config.js instead of doczrc.js:

/* gatsby-config.js */
const remarkGithub = require('remark-github');
module.exports = {
  plugins: [
    {
      resolve: 'gatsby-theme-docz',
      options: {
        // Note: these options are here instead of in doczrc.js
        // because of this bug: https://github.com/doczjs/docz/issues/1191
        mdPlugins: [remarkGithub],
      },
    },
  ],
};

Note that it's not necessary to move _all_ config to gatsby-config.js. It's certainly not ideal to have config in multiple places, but it does seem to work around this issue.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bugzpodder picture bugzpodder  ·  26Comments

Viktor19931 picture Viktor19931  ·  22Comments

PlayMa256 picture PlayMa256  ·  24Comments

godmar picture godmar  ·  24Comments

ivan-dalmet picture ivan-dalmet  ·  83Comments