Compare commits
1 Commits
v4
...
feat/previ
Author | SHA1 | Date | |
---|---|---|---|
|
a86c981e05 |
@ -213,7 +213,10 @@ export function renderPage(
|
|||||||
const doc = (
|
const doc = (
|
||||||
<html lang={lang}>
|
<html lang={lang}>
|
||||||
<Head {...componentData} />
|
<Head {...componentData} />
|
||||||
<body data-slug={slug}>
|
<body
|
||||||
|
data-slug={slug}
|
||||||
|
data-enable-preview={componentData.fileData.frontmatter?.preview ?? true}
|
||||||
|
>
|
||||||
<div id="quartz-root" class="page">
|
<div id="quartz-root" class="page">
|
||||||
<Body {...componentData}>
|
<Body {...componentData}>
|
||||||
{LeftComponent}
|
{LeftComponent}
|
||||||
|
@ -51,7 +51,13 @@ async function mouseEnterHandler(
|
|||||||
if (!contents) return
|
if (!contents) return
|
||||||
const html = p.parseFromString(contents, "text/html")
|
const html = p.parseFromString(contents, "text/html")
|
||||||
normalizeRelativeURLs(html, targetUrl)
|
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
|
if (elts.length === 0) return
|
||||||
|
|
||||||
const popoverElement = document.createElement("div")
|
const popoverElement = document.createElement("div")
|
||||||
|
@ -371,6 +371,11 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
|||||||
throw new Error(`Could not fetch ${targetUrl}`)
|
throw new Error(`Could not fetch ${targetUrl}`)
|
||||||
}
|
}
|
||||||
const html = p.parseFromString(contents ?? "", "text/html")
|
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)
|
normalizeRelativeURLs(html, targetUrl)
|
||||||
return [...html.getElementsByClassName("popover-hint")]
|
return [...html.getElementsByClassName("popover-hint")]
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user