docusaurus/packages/docusaurus-remark-plugin-npm2yarn
Alexey Pyltsyn f8fda885fc
chore(v2): prepare v2.0.0.alpha-72 release (#4440)
* chore(v2): prepare v2.0.0.alpha-72 release

* v2.0.0-alpha.72
2021-03-16 14:30:54 +03:00
..
src feat(v2): add support for sync to npm2yarn tabs (#3705) 2020-11-06 17:30:32 +01:00
example.png feat(v2): Extract npm2yarn plugin (#3469) 2020-10-15 19:30:12 +02:00
package.json chore(v2): prepare v2.0.0.alpha-72 release (#4440) 2021-03-16 14:30:54 +03:00
README.md chore(v2): fix windows Jest tests (#3959) 2020-12-28 19:50:12 +01:00

Remark plugin npm2yarn

Motivation:

Transforms npm bash command code blocks to Docusaurus tabs:

The following (remove the //):

// ```bash npm2yarn
// npm run build
// ```

Becomes:

npm2yarn tabs example

Note: it only works when used with Docusaurus themes that have the Tabs and TabItems components.

Install

npm install @docusaurus/remark-plugin-npm2yarn

It is a Remark plugin, not a Docusaurus plugin, so you have to install it as a Remark plugin in the config of your Docusaurus plugins.

module.exports = {
  presets: [
    [
      '@docusaurus/preset-classic',
      {
        docs: {
          // ...
          remarkPlugins: [
            [require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}],
          ],
        },
        blog: {
          // ...
          remarkPlugins: [
            [require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}],
          ],
        },
        pages: {
          // ...
          remarkPlugins: [
            [require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}],
          ],
        },
        // ...
      },
    ],
  ],
  // ...
};

Options

Property Type Default Description
sync boolean false Syncing tab choices (yarn and npm). See https://v2.docusaurus.io/docs/markdown-features/#syncing-tab-choices for details.