taglist, mermaid
This commit is contained in:
parent
2bfe90b7e6
commit
9d2024b11c
12 changed files with 149 additions and 41 deletions
28
quartz/resources.tsx
Normal file
28
quartz/resources.tsx
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { randomUUID } from "crypto"
|
||||
import { JSX } from "preact/jsx-runtime"
|
||||
|
||||
export type JSResource = {
|
||||
loadTime: 'beforeDOMReady' | 'afterDOMReady'
|
||||
moduleType?: 'module'
|
||||
} & ({
|
||||
src: string
|
||||
contentType: 'external'
|
||||
} | {
|
||||
script: string
|
||||
contentType: 'inline'
|
||||
})
|
||||
|
||||
export function JSResourceToScriptElement(resource: JSResource, preserve?: boolean): JSX.Element {
|
||||
const scriptType = resource.moduleType ?? 'application/javascript'
|
||||
if (resource.contentType === 'external') {
|
||||
return <script key={resource.src} src={resource.src} type={scriptType} spa-preserve={preserve} />
|
||||
} else {
|
||||
const content = resource.script
|
||||
return <script key={randomUUID()} type={scriptType} spa-preserve={preserve}>{content}</script>
|
||||
}
|
||||
}
|
||||
|
||||
export interface StaticResources {
|
||||
css: string[],
|
||||
js: JSResource[]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue