gatsby-remark-toc

`npm install gatsby-remark-toc --save`

This package exposed functionality that can be more easily implemented with gatsby-transformer-remark. See: https://www.gatsbyjs.org/packages/gatsby-transformer-remark/\#getting-table-of-contents
Last updated a year ago by dschau .
MIT · Original npm · Tarball · package.json
$ cnpm install gatsby-remark-toc 
SYNC missed versions from official npm registry.

Gatsby

gatsby-remark-toc

⚛️ ???? :rocket:

Adds a table of contents to Markdown files using mdast-util-toc

Current TravisCI build status. Current npm package version. Downloads per month on npm.

???? Install

npm install gatsby-remark-toc --save

???? How to use

// in your gatsby-config.js
plugins: [
  {
    resolve: 'gatsby-transformer-remark',
    options: {
      plugins: [
        {
          resolve: 'gatsby-remark-toc',
          options: {
            header: 'Table of Contents', // the custom header text
            include: [
              'content/**/*.md' // an include glob to match against
            ]
          }
        }
      ]
    }
  }
];

If you want your table of contents to appear at a specific place in your Markdown file, use the reuseExistingHeader option:

// in your gatsby-config.js
plugins: [
  {
    resolve: 'gatsby-transformer-remark',
    options: {
      plugins: [
        {
          resolve: 'gatsby-remark-toc',
          options: {
            header: 'Table of Contents', // the custom header text
            reuseExistingHeader: true, // searches for `Table of Contents` in your Markdown file and adds the list right after it
            include: [
              'content/**/*.md' // an include glob to match against
            ]
          }
        }
      ]
    }
  }
];

Use the orderedList option if you want to change the list type from <ul> to <ol>.

Additionally, you can pass custom options directly to mdast-util-toc like so:

// in your gatsby-config.js
plugins: [
  {
    resolve: 'gatsby-transformer-remark',
    options: {
      plugins: [
        {
          resolve: 'gatsby-remark-toc',
          options: {
            header: 'Table of Contents', // the custom header text
            include: [
              'content/**/*.md' // an include glob to match against
            ],
            mdastUtilTocOptions: {
              maxDepth: 2
            }
          }
        }
      ]
    }
  }
];

Current Tags

  • 1.2.0                                ...           latest (a year ago)

5 Versions

  • 1.2.0 [deprecated]           ...           a year ago
  • 1.1.0 [deprecated]           ...           2 years ago
  • 1.0.0 [deprecated]           ...           2 years ago
  • 1.0.0-rc.1                                ...           2 years ago
  • 1.0.0-rc.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 2
Dependencies (2)
Dev Dependencies (9)

Copyright 2014 - 2016 © taobao.org |