diff --git a/quartz/components/scripts/explorer.inline.ts b/quartz/components/scripts/explorer.inline.ts index ca5f5a8dd..9bb6bcb50 100644 --- a/quartz/components/scripts/explorer.inline.ts +++ b/quartz/components/scripts/explorer.inline.ts @@ -120,9 +120,9 @@ function setupExplorer() { } } }) - } else { + } else if (explorer?.dataset.tree) { // If tree is not in localStorage or config is disabled, use tree passed from Explorer as dataset - explorerState = JSON.parse(explorer?.dataset.tree as string) + explorerState = JSON.parse(explorer.dataset.tree) } } @@ -130,7 +130,8 @@ window.addEventListener("resize", setupExplorer, {passive: true}) document.addEventListener("nav", () => { setupExplorer() - const explorerContent = document.getElementById("explorer-ul") + observer.disconnect() + // select pseudo element at end of list const lastItem = document.getElementById("explorer-end") diff --git a/quartz/components/scripts/spa.inline.ts b/quartz/components/scripts/spa.inline.ts index 473363d3c..4d755904e 100644 --- a/quartz/components/scripts/spa.inline.ts +++ b/quartz/components/scripts/spa.inline.ts @@ -45,7 +45,14 @@ let p: DOMParser async function navigate(url: URL, isBack: boolean = false) { p = p || new DOMParser() const contents = await fetch(`${url}`) - .then((res) => res.text()) + .then((res) => { + const contentType = res.headers.get("content-type") + if (contentType?.startsWith("text/html")) { + return res.text() + } else { + window.location.assign(url) + } + }) .catch(() => { window.location.assign(url) }) diff --git a/quartz/plugins/transformers/links.ts b/quartz/plugins/transformers/links.ts index 8d16136f3..eec473c10 100644 --- a/quartz/plugins/transformers/links.ts +++ b/quartz/plugins/transformers/links.ts @@ -54,6 +54,16 @@ export const CrawlLinks: QuartzTransformerPlugin | undefined> = node.properties.className ??= [] node.properties.className.push(isAbsoluteUrl(dest) ? "external" : "internal") + // Check if the link has alias text + if ( + node.children.length === 1 && + node.children[0].type === "text" && + node.children[0].value !== dest + ) { + // Add the 'alias' class if the text content is not the same as the href + node.properties.className.push("alias") + } + if (opts.openLinksInNewTab) { node.properties.target = "_blank" } diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts index 628d06d73..261bc057f 100644 --- a/quartz/plugins/transformers/ofm.ts +++ b/quartz/plugins/transformers/ofm.ts @@ -183,7 +183,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin const fp = rawFp ?? "" const anchor = rawHeader?.trim().replace(/^#+/, "") const displayAnchor = anchor ? `#${slugAnchor(anchor)}` : "" - const displayAlias = rawAlias ?? anchor ?? "" + const displayAlias = rawAlias ?? rawHeader?.replace("#", "|") ?? "" const embedDisplay = value.startsWith("!") ? "!" : "" return `${embedDisplay}[[${fp}${displayAnchor}${displayAlias}]]` })