Skip to content

Crawling all heading tags of page and generating TOC automatically.

Notifications You must be signed in to change notification settings

Gnotes/table-of-contents

Repository files navigation

Table of contents

Crawling all heading tags of page and generating TOC automatically.

Styling TOC by your self.

Install

  • Module
npm i @xinghe/toc -S
# or
yarn add @xinghe/toc -S
  • CDN
<script src="https://unpkg.com/@xinghe/[email protected]/lib/index.umd.js" />

Usage

new TOC({ el: '#toc' });

Configuration

Field Type Required Comment
el HTMLElement、String Y the root element which toc needs to be mounted
mode String N the way of anchor, default to hash, but you can use scroll which means scrollIntoView in JS
container HTMLElement、String N the root element which contains headings, the default is document.body
selector String N css selector of heading tags, default is h1 ~ h6
beforeMount Function N life-cycle hook called before toc mount
onMounted Function N life-cycle hook called after toc mounted
cleanRoot Boolean N clean root element before mounting doms

About

Crawling all heading tags of page and generating TOC automatically.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published