Docusaurus: Error when including rehype plugins

Created on 26 Jul 2020  路  6Comments  路  Source: facebook/docusaurus

馃悰 Bug Report

Unable to add rehypePlugins in docusaurus.config.js. Results in following error during docuasaurus start and docusaurus build.

ValidationError: "rehypePlugins[0]" must be a string

Have you read the Contributing Guidelines on issues?

Yes.

To Reproduce

(Write your steps here:)

  1. npx @docusaurus/init@next init docusaurus classic
  2. npm i --save remark-math rehype-katex
  3. In docusaurus.config.js import the two packages and add to docs:
const katex = require("rehype-katex");
const math = require("remark-math");

module.exports = {
  // ...
  presets: [
    [
      "@docusaurus/preset-classic",
      {
        docs: {
          // It is recommended to set document id as docs home page (`docs/` path).
          homePageId: "doc1",
          sidebarPath: require.resolve("./sidebars.js"),
          remarkPlugins: [math],
          rehypePlugins: [katex],
          // Please change this to your repo.
          editUrl:
            "https://github.com/facebook/docusaurus/edit/master/website/",
        },
        // ...
      },
    ],
  ],
};

  1. docusaurus start

Expected behavior

Expect to be able to serve website.

Actual Behavior

docusaurus start

Starting the development server...
ValidationError: "rehypePlugins[0]" must be a string

(Write what happened. Add screenshots, if applicable.)

Your Environment

  • Docusaurus version used: 2.0.0-alpha.59
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Node 14.5.0
  • Operating system and version (desktop or mobile): Windows 10

Reproducible Demo

https://github.com/mattcorner/docusaurus-equations-error/blob/master/docusaurus.config.js

bug needs triage

All 6 comments

I should add that I get the same issue when following the documentation for adding rehype/remark plugins from the documentation:

https://v2.docusaurus.io/docs/markdown-features#configuring-plugins

Thanks, this is a mistake in the plugin validation. #3120 will fix this issue (and also other issues related to config validation)

This still seems to be an issue, following the docs at https://v2.docusaurus.io/docs/markdown-features#configuring-plugins I get an error in validation when using this config which is straight out of the docs

const rehypeTruncate = require("rehype-truncate");
....
rehypePlugins: [rehypeTruncate]
ValidationError: "rehypePlugins[0]" does not match any of the allowed types

@teikjun can you take a look please?

@mattmillerart thanks! It will be fixed in #3247

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lex111 picture lex111  路  3Comments

MoogyG picture MoogyG  路  3Comments

endiliey picture endiliey  路  3Comments

awibox picture awibox  路  3Comments

omry picture omry  路  3Comments