add flamethrower router

This commit is contained in:
Jacky Zhao 2023-06-07 22:38:45 -07:00
parent 317cce9314
commit 59109a8c1d
5 changed files with 16 additions and 9 deletions

15
package-lock.json generated
View file

@ -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",

View file

@ -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",

View file

@ -75,6 +75,7 @@ yargs(hideBin(process.argv))
stdin: {
contents: text,
loader: 'ts',
resolveDir: '.',
sourcefile: path.relative(path.resolve('.'), args.path),
},
write: false,

View file

@ -0,0 +1,3 @@
import flamethrower from 'flamethrower-router'
const router = flamethrower()
export default "SpaScript"

View file

@ -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) {