Simple and lightweight Table of contents.
let my_toc = new easy_toc( document.querySelector('.my-toc-wrapper'), {
include: [
'h1',
'h2',
'h3',
'h4',
'h5',
'h6'
],
exclude: [
'[data-no-toc]'
],
prefix: 'easy_toc_',
hierarchical: true,
anchor_nodename: 'div',
anchor_class: 'anchor'
} );
my_toc.init();
init()
// Init
my_toc.init();
update()
// Basically just an alias for init()
my_toc.update();
destroy()
// Destroy the current TOC
my_toc.destroy();
You can exclude headings with data-no-toc
or whatever is specified in settings.exclude
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
Headings with the same content still work. A counter will update the slug for the specific Heading
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.