Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leungwensen/toc-generator
generate table of content
https://github.com/leungwensen/toc-generator
Last synced: 29 days ago
JSON representation
generate table of content
- Host: GitHub
- URL: https://github.com/leungwensen/toc-generator
- Owner: leungwensen
- License: mit
- Created: 2016-02-02T08:02:26.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-17T03:42:25.000Z (over 8 years ago)
- Last Synced: 2024-09-17T01:41:32.450Z (about 2 months ago)
- Language: JavaScript
- Homepage: http://leungwensen.github.io/toc-generator/
- Size: 2.14 MB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [toc-generator](http://leungwensen.github.io/toc-generator/)
table of content generator.
[homepage](http://leungwensen.github.io/toc-generator/) | [demo](http://leungwensen.github.io/toc-generator/demo/)
## install
```
npm install toc-generator --save-dev
```## usage
```javascript
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](http://leungwensen.github.io/toc-generator/demo/)