var toc = require('{%= name %}');
gulp.task('toc', function() {
return gulp.src('foo/*.html')
.pipe(toc())
.pipe(gulp.dest('bar'));
});
Type: string
Default: #toc
(usage: <div id="toc"></div>
)
Specify the id for where the table of contents should be injected.
Example
toc({id: '#navigation'});
In your HTML, add the following:
<div id="navigation"></div>
Type: boolean
Default: undefined
Set to false
to disable anchors.
Example
toc({anchors: false});
Customize the template for creating anchors.
Type: function
Default
<a href="#${id}" name="${id}" class="anchor">
<span class="anchor-target" id="${id}"></span>
<span class="glyphicon glyphicon-link"></span>
</a>
Example
toc({
anchorTemplate: function(id) {
return `<a class="anchor" href="${id}" id="${id}"></a>`;
}
});
Heading selectors to use for generating the table of contents.
Type: string
Default: h1,h2
Example
Generate a table of contents for all headings h1-h4.
toc({selectors: 'h1,h2,h3,h4'});