toc-generator

0.0.20160318 • Public • Published

toc-generator

table of content generator.

homepage | demo

install

npm install toc-generator --save-dev

usage

import tg from 'toc-generator';
 
let toc = new tg.Toc(element, options);
//let toc = tg.generate(element, options);
/*
 element: optional, default is document.body
 options: optional, default is
 {
    anchorIdPrefix: 'toc-',
    maxDepth: 3,
 }
 */
 
toc.placeAt(container, position);
/*
 container: optional, default is document.body
 position: optional, validate value is one of
 [
    'before',
    'after',
    'replace',
    'only',
    'first',
    'last'
 ]
 */
 
toc.destroy();
/*
 will remove all anchors from element, and remove domNode of toc itself.
 */

demo

Package Sidebar

Install

npm i toc-generator

Weekly Downloads

2

Version

0.0.20160318

License

MIT

Last publish

Collaborators

  • leungwensen