From e9fb0ecb96a2de53cf5f060c4e151f539ca4b089 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Fri, 02 Feb 2024 05:19:51 +0000
Subject: [PATCH] fix: border radius on search preview
---
quartz/plugins/emitters/componentResources.ts | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/quartz/plugins/emitters/componentResources.ts b/quartz/plugins/emitters/componentResources.ts
index e8a81bc..5eb9718 100644
--- a/quartz/plugins/emitters/componentResources.ts
+++ b/quartz/plugins/emitters/componentResources.ts
@@ -13,6 +13,7 @@
import { googleFontHref, joinStyles } from "../../util/theme"
import { Features, transform } from "lightningcss"
import { transform as transpile } from "esbuild"
+import { write } from "./helpers"
type ComponentResources = {
css: string[]
@@ -93,7 +94,7 @@
function gtag() { dataLayer.push(arguments); }
gtag("js", new Date());
gtag("config", "${tagId}", { send_page_view: false });
-
+
document.addEventListener("nav", () => {
gtag("event", "page_view", {
page_title: document.title,
@@ -118,10 +119,10 @@
} else if (cfg.analytics?.provider === "umami") {
componentResources.afterDOMLoaded.push(`
const umamiScript = document.createElement("script")
- umamiScript.src = "https://analytics.umami.is/script.js"
+ umamiScript.src = cfg.analytics.host ?? "https://analytics.umami.is/script.js"
umamiScript.setAttribute("data-website-id", "${cfg.analytics.websiteId}")
umamiScript.async = true
-
+
document.head.appendChild(umamiScript)
`)
}
@@ -130,9 +131,11 @@
componentResources.afterDOMLoaded.push(spaRouterScript)
} else {
componentResources.afterDOMLoaded.push(`
- window.spaNavigate = (url, _) => window.location.assign(url)
- const event = new CustomEvent("nav", { detail: { url: document.body.dataset.slug } })
- document.dispatchEvent(event)`)
+ window.spaNavigate = (url, _) => window.location.assign(url)
+ window.addCleanup = () => {}
+ const event = new CustomEvent("nav", { detail: { url: document.body.dataset.slug } })
+ document.dispatchEvent(event)
+ `)
}
let wsUrl = `ws://localhost:${ctx.argv.wsPort}`
@@ -146,9 +149,9 @@
loadTime: "afterDOMReady",
contentType: "inline",
script: `
- const socket = new WebSocket('${wsUrl}')
- socket.addEventListener('message', () => document.location.reload())
- `,
+ const socket = new WebSocket('${wsUrl}')
+ socket.addEventListener('message', () => document.location.reload())
+ `,
})
}
}
@@ -168,7 +171,7 @@
getQuartzComponents() {
return []
},
- async emit(ctx, _content, resources, emit): Promise<FilePath[]> {
+ async emit(ctx, _content, resources): Promise<FilePath[]> {
// component specific scripts and styles
const componentResources = getComponentResources(ctx)
// important that this goes *after* component scripts
@@ -190,7 +193,8 @@
])
const fps = await Promise.all([
- emit({
+ write({
+ ctx,
slug: "index" as FullSlug,
ext: ".css",
content: transform({
@@ -207,12 +211,14 @@
include: Features.MediaQueries,
}).code.toString(),
}),
- emit({
+ write({
+ ctx,
slug: "prescript" as FullSlug,
ext: ".js",
content: prescript,
}),
- emit({
+ write({
+ ctx,
slug: "postscript" as FullSlug,
ext: ".js",
content: postscript,
--
Gitblit v1.10.0