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

gatsby-remark-table-of-contents

v2.0.0

Published

gatsby remark plugin to generate table of contents

Downloads

4,091

Readme

Table of Contents in Gatsby

Downloads Lines

Gatsby plugin using remark to generate a Table of Contents in markdown.

Installation

Requirements

This plugin requires gatsby-remark-autolink-headers to generate the anchor links.

npm i --save gatsby-remark-autolink-headers

Install gatsby-remark-table-of-contents

npm i --save gatsby-remark-table-of-contents

Global Configuration

Global configurations should be set in gatsby-config.js.

module.exports = ({ root }) => ({
  plugins: [
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-table-of-contents`,
            options: {
              exclude: "Table of Contents",
              tight: false,
              ordered: false,
              fromHeading: 1,
              toHeading: 6,
              className: "table-of-contents"
            },
          },
          `gatsby-remark-autolink-headers`
        ],
      },
    },
  ],
})

Use

Generate a table of contents:

```toc
# This code block gets replaced with the TOC
```

If you like to overwrite the global settings in place (camelCase or kebab-case):

```toc
# This code block gets replaced with the TOC
exclude: Table of Contents
tight: false
ordered: false
from-heading: 2
to-heading: 6
class-name: "table-of-contents"
```

Options

exclude

string? | array? — default: ''
Exclude titles matching this string (new RegExp('^(' + string + ')$', 'i')). If an array is passed the array gets joined with a pipe (new RegExp('^(' + array.join('|') + ')$', 'i')).

tight

boolean? — default: false
Tight list items.

ordered

boolean? — default: false
Creates an ordered list.

fromHeading

number? — default: 2
Minimum heading depth to include.

toHeading

number? — default: 6
Maximum heading depth to include.

className

string? — default: toc
Set the class-name of the generated div.

Example

Input

# Headline 1.0.0

## Table of Contents

```toc
exclude: Table of Contents
from-heading: 2
to-heading: 6
```

## Headline 1.1.0

### Headline 1.1.1

## Headline 1.2.0

Output

# Headline 1.0.0

## Table of Contents

-   [Headline 1.1.0](#headline-110)

    -   [Headline 1.1.1](#headline-111)

-   [Headline 1.2.0](#headline-120)

## Headline 1.1.0

### Headline 1.1.1

## Headline 1.2.0

License & Authors

MIT · Started by signalwerk supported by several contributors

Version

  • 1.0.0 – FIX: Bugfix when JSX/MDX is used (author: @zeropaper)
  • 0.2.0 – ADD: Option to set ordered (author: @thomasjungblut)
  • 0.1.0 – ADD: Option to set Class-Name (author: @panzerdp)
  • 0.0.9 – ADD: Multiple excludes can now be defined by arrays (author: @signalwerk)
  • 0.0.1 – Initial release (author: @signalwerk)