From 3a29f4c86ee7ed13fb8683b2728a856581e32de7 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Fri, 9 Jun 2023 19:58:58 -0700 Subject: [PATCH] add custom spa solution --- quartz/bootstrap-cli.mjs | 4 + quartz/components/Head.tsx | 6 +- quartz/components/scripts/spa.inline.ts | 133 +++++++++++++++++++++++- quartz/plugins/index.ts | 1 + 4 files changed, 138 insertions(+), 6 deletions(-) diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs index e9cda4e0..e6bb3f0a 100755 --- a/quartz/bootstrap-cli.mjs +++ b/quartz/bootstrap-cli.mjs @@ -71,6 +71,10 @@ yargs(hideBin(process.argv)) setup(build) { build.onLoad({ filter: /\.inline\.(ts|js)$/ }, async (args) => { let text = await promises.readFile(args.path, 'utf8') + // remove default exports that we manually inserted + text = text.replace('export default', '') + text = text.replace('export', '') + const transpiled = await esbuild.build({ stdin: { contents: text, diff --git a/quartz/components/Head.tsx b/quartz/components/Head.tsx index c56b8cbc..37c0abaa 100644 --- a/quartz/components/Head.tsx +++ b/quartz/components/Head.tsx @@ -9,7 +9,7 @@ export default function Head({ fileData, externalResources }: QuartzComponentPro const baseDir = resolveToRoot(slug) const iconPath = baseDir + "/static/icon.png" const ogImagePath = baseDir + "/static/og-image.png" - + return {title} @@ -24,7 +24,7 @@ export default function Head({ fileData, externalResources }: QuartzComponentPro - {css.map(href => )} - {js.filter(resource => resource.loadTime === "beforeDOMReady").map(resource =>