From 31e0b7c6f802cfab7250b7e9dfb321b3889ef6ca Mon Sep 17 00:00:00 2001
From: David Fischer <david@konst.fish>
Date: Sat, 09 Nov 2024 09:44:32 +0000
Subject: [PATCH] feat(comments): conditional display via frontmatter (#1566)
---
quartz/util/resources.tsx | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/quartz/util/resources.tsx b/quartz/util/resources.tsx
index a572d89..72ae9e6 100644
--- a/quartz/util/resources.tsx
+++ b/quartz/util/resources.tsx
@@ -16,6 +16,12 @@
}
)
+export type CSSResource = {
+ content: string
+ inline?: boolean
+ spaPreserve?: boolean
+}
+
export function JSResourceToScriptElement(resource: JSResource, preserve?: boolean): JSX.Element {
const scriptType = resource.moduleType ?? "application/javascript"
const spaPreserve = preserve ?? resource.spaPreserve
@@ -36,7 +42,24 @@
}
}
+export function CSSResourceToStyleElement(resource: CSSResource, preserve?: boolean): JSX.Element {
+ const spaPreserve = preserve ?? resource.spaPreserve
+ if (resource.inline ?? false) {
+ return <style>{resource.content}</style>
+ } else {
+ return (
+ <link
+ key={resource.content}
+ href={resource.content}
+ rel="stylesheet"
+ type="text/css"
+ spa-preserve={spaPreserve}
+ />
+ )
+ }
+}
+
export interface StaticResources {
- css: string[]
+ css: CSSResource[]
js: JSResource[]
}
--
Gitblit v1.10.0