npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

docusaurus-remark-plugin-tab-blocks

v3.1.0

Published

Turn Docusaurus code blocks into tab blocks

Downloads

2,135

Readme

docusaurus-remark-plugin-tab-blocks

version license packagephobia coverage

Turn Docusaurus code blocks into tab blocks.


This Docusaurus plugin transforms markdown code blocks into tabs. Just add the tab key to the language meta string:

```js tab
console.log("Hello JavaScript tab!");
```

```ts tab
console.log("Ahoy TypeScript tab!");
```

And you have:

[!NOTE]

A Docusaurus theme with the Tabs and TabItems components is required.

Install

npm add docusaurus-remark-plugin-tab-blocks

[!NOTE]

Current version of the plugin only works with Docusaurus 3. For Docusaurus 2, you should install [email protected].

Usage

Add the plugin to the remarkPlugins list of your Docusaurus configuration:

import tabBlocks from "docusaurus-remark-plugin-tab-blocks";

export default {
  presets: [
    [
      "@docusaurus/preset-classic",
      {
        blog: {
          remarkPlugins: [tabBlocks],
        },
        docs: {
          remarkPlugins: [
            [
              tabBlocks,
              // optional plugin configuration
              {
                labels: [
                  ["json", "JSON"],
                  ["jsx", "JSX"],
                  ["tsx", "TSX"],
                ],
              },
            ],
          ],
        },
        pages: {
          remarkPlugins: [tabBlocks],
        },
      },
    ],
  ],
};

API Reference

Plugin configuration

Configuration options can be passed to the plugin using the tuple form. See usage example above.

groupId

  • Type: string
  • Default: "code-examples"

The groupId property for all instances of Tabs component created by this plugin. Applicable only if sync option is set to true.

labels

  • Type: Array<[string, string]>
  • Default: [["js", "JavaScript"], ["ts", "TypeScript"]]

List with tuples with code block language attribute and tab label text.

sync

  • Type: boolean
  • Default: true

Whether tab choices should be synced between all tabs created by this plugin.

tab options

Each tab can be customized separately by assign a configuration object to the tab key. Keep in mind that the object must be parsable JSON.

label

  • Type: string

Sets custom tab label text.

```bash tab={"label":"npm"}
npm install docusaurus-remark-plugin-tab-blocks
```

```bash tab={"label":"yarn"}
yarn add docusaurus-remark-plugin-tab-blocks
```

span

  • Type: number

Makes a single tab wrap two or more code blocks.

```js tab={"span":2} title="SomeClass.js"
module.exports = class SomeClass {
  method(a, b) {}
};
```

```js title="SomeClass.test.js"
const SomeClass = require("./SomeClass");

// this and previous code blocks live in a single tab
```

```ts tab={"span":2} title="SomeClass.ts"
export class SomeClass {
  method(a: string, b: string): void {}
}
```

```ts title="SomeClass.test.ts"
import { SomeClass } from "./SomeClass";

// this and previous code blocks live in a single tab
```

The example above will be rendered like this:

License

MIT