add content cache to generated pages

just so that we don't waste work regenerating them over and over again -w-
This commit is contained in:
りき萌 2024-11-23 21:21:28 +01:00
parent 9022fb4ce9
commit 42eaa326ab
4 changed files with 127 additions and 14 deletions

View file

@ -104,9 +104,7 @@ class LinkedBranch extends Branch {
async loadTreePromise(_initiator) {
try {
let response = await fetch(
`${TREEHOUSE_SITE}/${this.linkedTree}.html`
);
let response = await fetch(`${TREEHOUSE_SITE}/${this.linkedTree}`);
if (response.status == 404) {
throw `Hmm, seems like the tree "${this.linkedTree}" does not exist.`;
}
@ -127,7 +125,9 @@ class LinkedBranch extends Branch {
// No need to await for the import because we don't use the resulting module.
// Just fire and forger 💀
// and let them run in parallel.
let url = URL.createObjectURL(new Blob([script.textContent], { type: "text/javascript" }))
let url = URL.createObjectURL(
new Blob([script.textContent], { type: "text/javascript" }),
);
import(url);
}
} catch (error) {
@ -257,10 +257,7 @@ async function expandLinkedBranch() {
let currentlyHighlightedBranch = getCurrentlyHighlightedBranch();
if (currentlyHighlightedBranch.length > 0) {
let linkedBranch = document.getElementById(currentlyHighlightedBranch);
if (
linkedBranch.children.length > 0 &&
linkedBranch.children[0].tagName == "DETAILS"
) {
if (linkedBranch.children.length > 0 && linkedBranch.children[0].tagName == "DETAILS") {
expandDetailsRecursively(linkedBranch.children[0]);
}
}