Skip to content

Latest commit

 

History

History
88 lines (57 loc) · 1.23 KB

.verb.md

File metadata and controls

88 lines (57 loc) · 1.23 KB

Usage

var toc = require('{%= name %}');

gulp.task('toc', function() {
  return gulp.src('foo/*.html')
    .pipe(toc())
    .pipe(gulp.dest('bar'));
});

Options

options.id

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>

options.anchors

Type: boolean

Default: undefined

Set to false to disable anchors.

Example

toc({anchors: false});

options.anchorTemplate

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>`;
  }
});

options.selectors

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'});