From a86c981e052a10a269d4c2f6f01a1b5c54280c62 Mon Sep 17 00:00:00 2001 From: Aaron <29749331+aarnphm@users.noreply.github.com> Date: Sun, 11 Feb 2024 09:53:31 -0500 Subject: [PATCH] feat(preview): manual disabled given files Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com> --- quartz/components/renderPage.tsx | 5 ++++- quartz/components/scripts/popover.inline.ts | 8 +++++++- quartz/components/scripts/search.inline.ts | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/quartz/components/renderPage.tsx b/quartz/components/renderPage.tsx index 4643d0a3a..51b35e1f7 100644 --- a/quartz/components/renderPage.tsx +++ b/quartz/components/renderPage.tsx @@ -213,7 +213,10 @@ export function renderPage( const doc = ( - +
{LeftComponent} diff --git a/quartz/components/scripts/popover.inline.ts b/quartz/components/scripts/popover.inline.ts index 0251834cb..b256e6ee4 100644 --- a/quartz/components/scripts/popover.inline.ts +++ b/quartz/components/scripts/popover.inline.ts @@ -51,7 +51,13 @@ async function mouseEnterHandler( if (!contents) return const html = p.parseFromString(contents, "text/html") normalizeRelativeURLs(html, targetUrl) - const elts = [...html.getElementsByClassName("popover-hint")] + let elts: Element[] + if (html.body.dataset.enablePreview === "false") { + const noPreview = document.createElement("div") + noPreview.innerHTML = `

Preview is disabled for this page.

` + elts = [noPreview] + } else elts = [...html.getElementsByClassName("popover-hint")] + if (elts.length === 0) return const popoverElement = document.createElement("div") diff --git a/quartz/components/scripts/search.inline.ts b/quartz/components/scripts/search.inline.ts index a75f4ff46..7f4fead80 100644 --- a/quartz/components/scripts/search.inline.ts +++ b/quartz/components/scripts/search.inline.ts @@ -371,6 +371,11 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => { throw new Error(`Could not fetch ${targetUrl}`) } const html = p.parseFromString(contents ?? "", "text/html") + if (html.body.dataset.enablePreview === "false") { + const noPreview = document.createElement("div") + noPreview.innerHTML = `

Preview is disabled for this page.

` + return [noPreview] + } normalizeRelativeURLs(html, targetUrl) return [...html.getElementsByClassName("popover-hint")] })