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 🙏

© 2026 – Pkg Stats / Ryan Hefner

docusaurus-plugin-version-diff-sign

v1.0.3

Published

Adds version diff signs to Docusaurus docs headings, sidebar items, and table of contents entries.

Readme

docusaurus-plugin-version-diff-sign

docusaurus-plugin-version-diff-sign adds version diff signs to Docusaurus docs content by comparing the current docs version against the immediately previous docs version.

It computes diff metadata at build time and uses that metadata at runtime to decorate:

  • page headings
  • sidebar doc links
  • table of contents entries

Quick Start

Minimal setup:

import type { Config } from '@docusaurus/types';

const config: Config = {
  plugins: ['docusaurus-plugin-version-diff-sign'],
};

export default config;

With the default renderer:

  • page headings render text pills
  • sidebar items render dots
  • TOC entries render dots

Local Development

This repository includes a minimal Docusaurus site under examples/minimal-site so you can verify sign rendering before publishing a change.

Install the development dependencies once:

pnpm install

Then start the local site:

pnpm run dev:site

Useful routes:

  • /docs/guide/start: automatic heading and TOC diffs
  • /docs/guide/override: frontmatter overrides
  • /docs/guide/new-page: a page that exists only in the latest version

For CI-style verification, you can also build the site:

pnpm run build:site

The development site loads the compiled plugin from lib, so rebuild the package after plugin changes before refreshing or restarting the site:

pnpm run build:package

Example with options: This disables TOC signs and changes the built-in sign colors for headings and sidebar items.

import type { Config } from '@docusaurus/types';

const config: Config = {
  plugins: [
    [
      'docusaurus-plugin-version-diff-sign',
      {
        targets: {
          toc: false,
        },
        sign: {
          heading: {
            color: '#0f766e',
          },
          sidebar: {
            color: '#f59e0b',
          },
        },
      },
    ],
  ],
};

export default config;

Options

The plugin options are:

{
  targets?: {
    sidebar?: boolean;
    toc?: boolean;
    headings?: boolean;
  };
  headingLevels?: number[];
  ignoreWhitespace?: boolean;
  sign?: {
    heading?: {
      type?: 'dot' | 'pill';
      color?: string;
      componentPath?: string;
    };
    sidebar?: {
      type?: 'dot' | 'pill';
      color?: string;
      componentPath?: string;
    };
    toc?: {
      type?: 'dot' | 'pill';
      color?: string;
      componentPath?: string;
    };
  };
  paths?: {
    routeBasePath?: string;
    cacheFile?: string;
  };
}

Options:

  • targets: turns rendering on or off for headings, sidebar items, and TOC items independently. Defaults to headings: true, sidebar: true, and toc: true.
  • headingLevels: controls which heading levels are tracked for both heading pills and TOC dots. Defaults to [1, 2, 3].
  • ignoreWhitespace: ignores whitespace-only content changes when true. Defaults to true.
  • sign: configures per-target sign customization. Use type to choose the built-in shape, color to tweak it, or componentPath to replace it completely. Defaults are heading.type: 'pill', sidebar.type: 'dot', and toc.type: 'dot'.
  • paths: advanced overrides for route base path and cache location. Defaults to routeBasePath: 'docs' and cacheFile: '.docusaurus/docusaurus-plugin-version-diff-sign.cache.json'.

Customization

Choose the lightest customization that fits your use case:

  • Use sign.<target>.color when you only want to change the built-in sign color.
  • Use CSS overrides when you want to keep the built-in sign but adjust its size, spacing, typography, or shape.
  • Use sign.<target>.componentPath when you want to replace the built-in sign completely.

1. Color only

If you only want to adjust the built-in sign color, configure sign.<target>.color:

import type { Config } from '@docusaurus/types';

const config: Config = {
  plugins: [
    [
      'docusaurus-plugin-version-diff-sign',
      {
        targets: {
          toc: false,
        },
        sign: {
          heading: {
            color: '#0f766e',
          },
          sidebar: {
            color: '#f59e0b',
          },
        },
      },
    ],
  ],
};

export default config;

This keeps the built-in pill and dot renderers, but changes their colors for the configured targets.

You can also switch the built-in sign shape per target:

sign: {
  toc: {
    type: 'pill',
  },
}

2. Fine-tune the built-in sign with CSS

The default renderer attaches stable target and state classes so you can restyle signs without changing the diff logic.

.version-diff-sign.in-heading.is-new {
  background: #0f766e;
  color: white;
}

.version-diff-sign.in-sidebar.is-updated,
.version-diff-sign.in-toc.is-updated {
  background: #f59e0b;
}

3. Replace the sign completely

To replace the built-in sign renderer for a specific target, point sign.<target>.componentPath at a component in your site:

import type { Config } from '@docusaurus/types';

const config: Config = {
  plugins: [
    [
      'docusaurus-plugin-version-diff-sign',
      {
        sign: {
          heading: {
            color: '#0f766e',
            componentPath: './src/components/HeadingVersionDiffBadge.tsx',
          },
        },
      },
    ],
  ],
};

export default config;

Example custom renderer:

import type { VersionDiffRendererProps } from 'docusaurus-plugin-version-diff-sign';

export default function VersionDiffBadge({
  state,
  target,
  type,
  color,
  className,
}: VersionDiffRendererProps) {
  return (
    <span
      className={[
        className,
        'my-sign',
        `my-sign--${target}`,
        `my-sign--${type}`,
        `my-sign--${state}`,
      ]
        .filter(Boolean)
        .join(' ')}
      style={{
        color,
        fontSize: type === 'pill' ? '0.75rem' : '0.625rem',
        fontWeight: 700,
        marginInlineStart: '0.5rem',
      }}
    >
      {state === 'new' ? 'NEW' : 'UPDATED'}
    </span>
  );
}

The renderer receives:

  • state: 'new' | 'updated'
  • target: 'heading' | 'sidebar' | 'toc'
  • type: 'pill' | 'dot'
  • color: the configured target color when provided
  • docId: current document unversionedId when available
  • headingId: current heading id for heading and TOC targets when available
  • headingLevel: heading level for heading and TOC targets when available
  • className: the plugin-provided class name for the rendered element

Frontmatter overrides

You can override automatic diff states in a document frontmatter block:

---
versionDiff:
  headingLevels: [2]
  page: updated
  headings:
    request-connection-interval-change: none
    write-operations: updated
---

versionDiff.headingLevels accepts an array of heading levels from 1 to 6 and overrides the plugin-level setting for that page.

versionDiff.page and each versionDiff.headings.<headingId> support these values:

  • auto
  • none
  • new
  • updated

versionDiff.page overrides both the page state and the title state. versionDiff.headings overrides individual heading states by heading id.

More Details

See docs/SPEC.md for the behavior contract and docs/ARCHITECTURE.md for implementation details.

Known Limitations

  • Cache behavior is not finalized yet and may change in a future update.
  • Only the current docs version and the immediately previous version are compared.
  • Arbitrary version-pair comparison is not supported.
  • Sidebar structure diffing is not supported as a first-class feature.