From 6ecdcb5e24f2783e6fa73de69e848f0f319c4fc4 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Wed, 13 Sep 2023 05:55:50 +0000
Subject: [PATCH] feat: resolve block references in obsidian markdown

---
 quartz/components/renderPage.tsx |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/quartz/components/renderPage.tsx b/quartz/components/renderPage.tsx
index ab93709..25297f2 100644
--- a/quartz/components/renderPage.tsx
+++ b/quartz/components/renderPage.tsx
@@ -2,8 +2,8 @@
 import { QuartzComponent, QuartzComponentProps } from "./types"
 import HeaderConstructor from "./Header"
 import BodyConstructor from "./Body"
-import { JSResourceToScriptElement, StaticResources } from "../resources"
-import { CanonicalSlug, pathToRoot } from "../path"
+import { JSResourceToScriptElement, StaticResources } from "../util/resources"
+import { FullSlug, RelativeURL, joinSegments } from "../util/path"
 
 interface RenderComponents {
   head: QuartzComponent
@@ -16,18 +16,20 @@
 }
 
 export function pageResources(
-  slug: CanonicalSlug,
+  baseDir: FullSlug | RelativeURL,
   staticResources: StaticResources,
 ): StaticResources {
-  const baseDir = pathToRoot(slug)
-
-  const contentIndexPath = baseDir + "/static/contentIndex.json"
+  const contentIndexPath = joinSegments(baseDir, "static/contentIndex.json")
   const contentIndexScript = `const fetchData = fetch(\`${contentIndexPath}\`).then(data => data.json())`
 
   return {
-    css: [baseDir + "/index.css", ...staticResources.css],
+    css: [joinSegments(baseDir, "index.css"), ...staticResources.css],
     js: [
-      { src: baseDir + "/prescript.js", loadTime: "beforeDOMReady", contentType: "external" },
+      {
+        src: joinSegments(baseDir, "prescript.js"),
+        loadTime: "beforeDOMReady",
+        contentType: "external",
+      },
       {
         loadTime: "beforeDOMReady",
         contentType: "inline",
@@ -36,7 +38,7 @@
       },
       ...staticResources.js,
       {
-        src: baseDir + "/postscript.js",
+        src: joinSegments(baseDir, "postscript.js"),
         loadTime: "afterDOMReady",
         moduleType: "module",
         contentType: "external",
@@ -46,7 +48,7 @@
 }
 
 export function renderPage(
-  slug: CanonicalSlug,
+  slug: FullSlug,
   componentData: QuartzComponentProps,
   components: RenderComponents,
   pageResources: StaticResources,

--
Gitblit v1.10.0