Fix the sidebar in recent versions of Hugo (#1551)

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
Kévin Commaille 2023-06-27 23:24:22 +02:00 committed by GitHub
parent 30845e189f
commit a6eb381ebb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 70 deletions

View file

@ -111,11 +111,18 @@ function makeToc() {
const section = makeTocSection(tocTargets, 0);
nav.appendChild(section.content);
// append title and content to the #toc placeholder
const toc = document.body.querySelector("#toc");
// build the TOC and append to it title and content
const toc = document.createElement("div");
toc.id = "toc";
toc.appendChild(title);
toc.appendChild(nav);
// append TOC to the section navigation
const section_nav = document.body.querySelector("#td-section-nav");
let hr = document.createElement("hr");
section_nav.appendChild(hr);
section_nav.appendChild(toc);
// tell ToC items about any rendered-data headings they contain
setTocItemChildren(section.content, headings);
}