docusaurus/packages/docusaurus-remark-plugin-npm2yarn
Oliver Ullman 1366c31201
feat(core): allow sourcing from multiple static directories (#4095)
* [WIP] Implementaion of multiple directory static sourcing

* Move default to validation

* Update test

* Refactor

* Port to MDX loader

* Fix

* Move dogfooding assets

* Doc writeup

* Restore assets

* Support absolute paths

* Dogfood absolute path

* Fix

* More tests

* Fix snapshots

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
2021-11-18 22:26:26 +08:00
..
src feat(core): allow sourcing from multiple static directories (#4095) 2021-11-18 22:26:26 +08:00
example.png feat(v2): Extract npm2yarn plugin (#3469) 2020-10-15 19:30:12 +02:00
package.json refactor(remark-plugin-npm2yarn): migrate package to TS (#5931) 2021-11-12 21:21:16 +08:00
README.md chore: rename v2.docusaurus.io urls after domain switch + redirect + cleanups (#4490) 2021-03-22 20:57:49 +01:00
tsconfig.json refactor(remark-plugin-npm2yarn): migrate package to TS (#5931) 2021-11-12 21:21:16 +08: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://docusaurus.io/docs/markdown-features/#syncing-tab-choices for details.