Cleanup the Javascript and CSS of our custom TOC
This commit is contained in:
parent
72f915aaca
commit
4cbcb44d70
2 changed files with 3 additions and 15 deletions
|
|
@ -10,14 +10,6 @@
|
|||
min-width: 50px;
|
||||
}
|
||||
|
||||
.previous {
|
||||
/*
|
||||
adjust the space between the left sidebar or the left side of the screen
|
||||
and the button that leads to the previous page
|
||||
*/
|
||||
margin-left: var(--page-padding);
|
||||
}
|
||||
|
||||
@media only screen {
|
||||
@media (max-width: 1179px) {
|
||||
.sidebar-hidden #sidetoc {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@ function updatePageToc(elem = undefined) {
|
|||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("sidetoc") === null) {
|
||||
if (document.getElementById("sidetoc") === null &&
|
||||
document.getElementsByClassName("header").length > 0) {
|
||||
// The sidetoc element doesn't exist yet, let's create it
|
||||
|
||||
// Create the empty sidetoc and pagetoc elements
|
||||
|
|
@ -80,16 +81,11 @@ if (document.getElementById("sidetoc") === null) {
|
|||
sidetoc.id = "sidetoc";
|
||||
pagetoc.id = "pagetoc";
|
||||
sidetoc.appendChild(pagetoc);
|
||||
|
||||
|
||||
// And append them to the current DOM
|
||||
const main = document.querySelector('main');
|
||||
main.insertBefore(sidetoc, main.firstChild);
|
||||
}
|
||||
|
||||
if (document.getElementsByClassName("header").length <= 1) {
|
||||
// There's one or less headings, we don't need a page table of contents
|
||||
document.getElementById("sidetoc").remove();
|
||||
} else {
|
||||
// Populate sidebar on load
|
||||
window.addEventListener("load", () => {
|
||||
for (const header of document.getElementsByClassName("header")) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue