From c874e7e9378a5ba895870e9680484fb4af5c6e93 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Sat, 19 Aug 2023 22:52:25 +0000
Subject: [PATCH] base path refactor to better support subpath hosting
---
quartz/components/renderPage.tsx | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/quartz/components/renderPage.tsx b/quartz/components/renderPage.tsx
index 171c414..a1d5fee 100644
--- a/quartz/components/renderPage.tsx
+++ b/quartz/components/renderPage.tsx
@@ -3,7 +3,7 @@
import HeaderConstructor from "./Header"
import BodyConstructor from "./Body"
import { JSResourceToScriptElement, StaticResources } from "../util/resources"
-import { CanonicalSlug, pathToRoot } from "../util/path"
+import { FullSlug, joinSegments, pathToRoot } from "../util/path"
interface RenderComponents {
head: QuartzComponent
@@ -15,19 +15,20 @@
footer: QuartzComponent
}
-export function pageResources(
- slug: CanonicalSlug,
- staticResources: StaticResources,
-): StaticResources {
+export function pageResources(slug: FullSlug, 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",
@@ -46,7 +47,7 @@
}
export function renderPage(
- slug: CanonicalSlug,
+ slug: FullSlug,
componentData: QuartzComponentProps,
components: RenderComponents,
pageResources: StaticResources,
--
Gitblit v1.10.0