From 94a54698ab7f29a609ca90033c1384a7ec5f5e65 Mon Sep 17 00:00:00 2001
From: Emile Bangma <ewjbangma@hotmail.com>
Date: Sat, 09 Mar 2024 16:59:55 +0000
Subject: [PATCH] fix(resources): Use full path to font when cdnCache is false (#976)
---
quartz/plugins/emitters/componentResources.ts | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/quartz/plugins/emitters/componentResources.ts b/quartz/plugins/emitters/componentResources.ts
index 290cb6f..eae496e 100644
--- a/quartz/plugins/emitters/componentResources.ts
+++ b/quartz/plugins/emitters/componentResources.ts
@@ -120,12 +120,21 @@
} else if (cfg.analytics?.provider === "umami") {
componentResources.afterDOMLoaded.push(`
const umamiScript = document.createElement("script")
- umamiScript.src = ${cfg.analytics.host} ?? "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)
`)
+ } else if (cfg.analytics?.provider === "goatcounter") {
+ componentResources.afterDOMLoaded.push(`
+ const goatcounterScript = document.createElement("script")
+ goatcounterScript.src = "${cfg.analytics.scriptSrc ?? "https://gc.zgo.at/count.js"}"
+ goatcounterScript.async = true
+ goatcounterScript.setAttribute("data-goatcounter",
+ "https://${cfg.analytics.websiteId}.${cfg.analytics.host ?? "goatcounter.com"}/count")
+ document.head.appendChild(goatcounterScript)
+ `)
}
if (cfg.enableSPA) {
@@ -196,10 +205,6 @@
const cfg = ctx.cfg.configuration
// component specific scripts and styles
const componentResources = getComponentResources(ctx)
- // important that this goes *after* component scripts
- // as the "nav" event gets triggered here and we should make sure
- // that everyone else had the chance to register a listener for it
-
let googleFontsStyleSheet = ""
if (fontOrigin === "local") {
// let the user do it themselves in css
@@ -223,7 +228,7 @@
googleFontsStyleSheet = googleFontsStyleSheet.replace(
url,
- `/static/fonts/${filename}.ttf`,
+ `https://${cfg.baseUrl}/static/fonts/${filename}.ttf`,
)
promises.push(
@@ -247,12 +252,15 @@
}
}
+ // important that this goes *after* component scripts
+ // as the "nav" event gets triggered here and we should make sure
+ // that everyone else had the chance to register a listener for it
addGlobalPageResources(ctx, resources, componentResources)
const stylesheet = joinStyles(
ctx.cfg.configuration.theme,
- ...componentResources.css,
googleFontsStyleSheet,
+ ...componentResources.css,
styles,
)
const [prescript, postscript] = await Promise.all([
--
Gitblit v1.10.0