facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
56.68k stars 8.52k forks source link

[v2] custom configuration for remark-admonitions does not work #2447

Closed Kimi-Gao closed 4 years ago

Kimi-Gao commented 4 years ago

🐛 Bug Report

custom configuration for remark-admonitions does not work.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

// docusaurus.config.js
module.exports = {
  presets: [
    [
      '@docusaurus/preset-classic',
      {
        docs: {
          // options for remark-admonitions
          admonitions: {
            customTypes: {
              kk: {
                keyword: 'kk',
                svg:
                  '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"/></svg>'
              },
            }
          },
        },
      },
    ],
  ],
};

adding these lines in md file:

:::kk

test custom admonitions.

:::

Expected behavior

custom admonition can render correctly

Actual Behavior

Your Environment

yangshun commented 4 years ago

cc @elviswolcott

elviswolcott commented 4 years ago

It looks like the root of the problem is that the plugin and options tuple was being flattened by concat https://github.com/facebook/docusaurus/blob/08616997dad3fcc567026f8beed8c8b986371f73/packages/docusaurus-preset-classic/src/index.js#L20-L25 resulting in something like

{ remarkPlugins: [plugin, config] }

instead of

{ remarkPlugins: [ [plugin, config] ] }
lex111 commented 4 years ago

@elviswolcott could you please fix this?

elviswolcott commented 4 years ago

@lex111 PR is up 😄