Skip to content

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

Description

@versipellis

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions