jdsteinbach / eleventy-plugin-toc

11ty plugin to generate a TOC from page content
62 stars 19 forks source link

<h2> TOCs rendering, but not <h3> or <h4> #32

Open versipellis opened 3 years ago

versipellis commented 3 years ago

As the title states, <h2> renders fine, but <h3> and <h4> tags do not, even though they are after <h2>, and correspondingly have their own IDs.

Using the default settings:

const pluginTOC = require('eleventy-plugin-toc', {
  tags: ['h2', 'h3', 'h4'], // which heading tags are selected headings must each have an ID attribute
  wrapper: 'nav',           // element to put around the root `ol`/`ul`
  wrapperClass: 'toc',      // class for the element around the root `ol`/`ul`
  ul: false,                // if to use `ul` instead of `ol`
  flat: false,              // if subheadings should appear as child of parent or as a sibling
});

Minimum reproducible example:

---
title: Title
layout: post.njk
---
<h2 id="header-test1">test1</h2>
<h3 id="header-test2">test2</h3>
<h4 id="header-test3">test3</h4>