feat(preview): manual disabled given files
Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
This commit is contained in:
parent
ab80eba794
commit
a86c981e05
@ -213,7 +213,10 @@ export function renderPage(
|
||||
const doc = (
|
||||
<html lang={lang}>
|
||||
<Head {...componentData} />
|
||||
<body data-slug={slug}>
|
||||
<body
|
||||
data-slug={slug}
|
||||
data-enable-preview={componentData.fileData.frontmatter?.preview ?? true}
|
||||
>
|
||||
<div id="quartz-root" class="page">
|
||||
<Body {...componentData}>
|
||||
{LeftComponent}
|
||||
|
@ -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 = `<p>Preview is disabled for this page.</p>`
|
||||
elts = [noPreview]
|
||||
} else elts = [...html.getElementsByClassName("popover-hint")]
|
||||
|
||||
if (elts.length === 0) return
|
||||
|
||||
const popoverElement = document.createElement("div")
|
||||
|
@ -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 = `<p>Preview is disabled for this page.</p>`
|
||||
return [noPreview]
|
||||
}
|
||||
normalizeRelativeURLs(html, targetUrl)
|
||||
return [...html.getElementsByClassName("popover-hint")]
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user