fix: dont call toc on load
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Evan Reichard 2025-04-26 08:04:39 -04:00
parent 5cbef19507
commit 48bffb5153

View File

@ -64,14 +64,23 @@ function populateMetadata(data) {
let [titleEl, authorEl] = document.querySelectorAll("#top-bar p + p");
titleEl.innerText = data.title;
authorEl.innerText = data.author;
populateTOC();
}
/**
* Populate the Table of Contents
**/
function populateTOC() {
if (!currentReader.book.navigation.toc) {
console.warn("[populateTOC] No TOC");
return;
}
let tocEl = document.querySelector("#toc");
if (!tocEl) {
console.warn("[populateTOC] No TOC Element");
return;
}
// Parse the Table of Contents
let parsedTOC = currentReader.book.navigation.toc.reduce((agg, item) => {
let sectionTitle = item.label.trim();
@ -104,7 +113,7 @@ function populateTOC() {
listItem.textContent = item.title;
listEl.appendChild(listItem);
});
document.querySelector("#toc").appendChild(listEl);
tocEl.appendChild(listEl);
}
/**