From 8e36d2a677535e98f291a625773f70d6e443a549 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Wed, 7 Jun 2023 22:38:45 -0700 Subject: [PATCH] add flamethrower router --- package-lock.json | 15 ++++++--------- package.json | 1 + quartz/bootstrap-cli.mjs | 1 + quartz/components/scripts/spa.inline.ts | 3 +++ quartz/plugins/index.ts | 5 +++++ 5 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 quartz/components/scripts/spa.inline.ts diff --git a/package-lock.json b/package-lock.json index a635676a..4847103d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "chalk": "^4.1.2", "cli-spinner": "^0.2.10", "esbuild-sass-plugin": "^2.9.0", + "flamethrower-router": "^0.0.0-meme.12", "github-slugger": "^2.0.0", "globby": "^13.1.4", "gray-matter": "^4.0.3", @@ -33,7 +34,6 @@ "remark-frontmatter": "^4.0.1", "remark-gfm": "^3.0.1", "remark-math": "^5.1.1", - "remark-obsidian-callout": "^1.1.3", "remark-parse": "^10.0.1", "remark-rehype": "^10.1.0", "remark-smartypants": "^2.0.0", @@ -1523,6 +1523,11 @@ "node": ">=8" } }, + "node_modules/flamethrower-router": { + "version": "0.0.0-meme.12", + "resolved": "https://registry.npmjs.org/flamethrower-router/-/flamethrower-router-0.0.0-meme.12.tgz", + "integrity": "sha512-PWcNrjzItwk61RTk/SbbKJNcAgl6qCXH8xkZjGjUGV/dgKAnURci+k+Yk8emubUQWTdAd1kSqujy0VRjoeEgxg==" + }, "node_modules/foreground-child": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", @@ -3405,14 +3410,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/remark-obsidian-callout": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/remark-obsidian-callout/-/remark-obsidian-callout-1.1.3.tgz", - "integrity": "sha512-q2jZgPMHP5Wyq0WgeGdwboPoepqN7Ib77iWagEKThZjtl1wUd7/f2tdErdPr/LeZu9K7I6r52XylwhLs5GJi9g==", - "dependencies": { - "unist-util-visit": "^4.1.2" - } - }, "node_modules/remark-parse": { "version": "10.0.2", "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-10.0.2.tgz", diff --git a/package.json b/package.json index 5bb2cb09..fe5a5178 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "chalk": "^4.1.2", "cli-spinner": "^0.2.10", "esbuild-sass-plugin": "^2.9.0", + "flamethrower-router": "^0.0.0-meme.12", "github-slugger": "^2.0.0", "globby": "^13.1.4", "gray-matter": "^4.0.3", diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs index f9b53043..e9cda4e0 100755 --- a/quartz/bootstrap-cli.mjs +++ b/quartz/bootstrap-cli.mjs @@ -75,6 +75,7 @@ yargs(hideBin(process.argv)) stdin: { contents: text, loader: 'ts', + resolveDir: '.', sourcefile: path.relative(path.resolve('.'), args.path), }, write: false, diff --git a/quartz/components/scripts/spa.inline.ts b/quartz/components/scripts/spa.inline.ts new file mode 100644 index 00000000..4020c230 --- /dev/null +++ b/quartz/components/scripts/spa.inline.ts @@ -0,0 +1,3 @@ +import flamethrower from 'flamethrower-router' +const router = flamethrower() +export default "SpaScript" diff --git a/quartz/plugins/index.ts b/quartz/plugins/index.ts index 01348c9e..6d5d8405 100644 --- a/quartz/plugins/index.ts +++ b/quartz/plugins/index.ts @@ -4,6 +4,7 @@ import { StaticResources } from '../resources' import { googleFontHref, joinStyles } from '../theme' import { EmitCallback, PluginTypes } from './types' import styles from '../styles/base.scss' +import spaRouterScript from '../components/scripts/spa.inline' export type ComponentResources = { css: string[], @@ -31,6 +32,10 @@ export function emitComponentResources(cfg: GlobalConfiguration, resources: Stat afterDOMLoaded: [] } + if (cfg.enableSPA) { + componentResources.afterDOMLoaded.push(spaRouterScript) + } + for (const component of allComponents) { const { css, beforeDOMLoaded, afterDOMLoaded } = component if (css) {