inline scripts

This commit is contained in:
Jacky Zhao
2023-06-03 15:07:19 -04:00
parent 29fc468ff1
commit fa8a4a6f52
19 changed files with 187 additions and 69 deletions

View File

@ -8,10 +8,9 @@ export interface HeadProps {
externalResources: StaticResources
}
export default function({ title, description, slug, externalResources }: HeadProps) {
export function Component({ title, description, slug, externalResources }: HeadProps) {
const { css, js } = externalResources
const baseDir = resolveToRoot(slug)
const stylePath = baseDir + "/index.css"
const iconPath = baseDir + "/static/icon.png"
const ogImagePath = baseDir + "/static/og-image.png"
return <head>
@ -28,16 +27,7 @@ export default function({ title, description, slug, externalResources }: HeadPro
<meta name="generator" content="Quartz" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link rel="stylesheet" type="text/css" href={stylePath} />
{css.map(href => <link key={href} href={href} rel="stylesheet" type="text/css" />)}
{js.filter(resource => resource.loadTime === "beforeDOMReady").map(resource => <script key={resource.src} src={resource.src} />)}
{js.filter(resource => resource.loadTime === "beforeDOMReady").map(resource => <script key={resource.src} {...resource} />)}
</head>
}
export function beforeDOMLoaded() {
}
export function onDOMLoaded() {
}

View File

@ -5,10 +5,10 @@ export interface HeaderProps {
slug: string
}
export default function({ title, slug }: HeaderProps) {
export function Component({ title, slug }: HeaderProps) {
const baseDir = resolveToRoot(slug)
return <header>
<h1><a href={baseDir}>{title}</a></h1>
</header>
}

View File

@ -0,0 +1,3 @@
export default "Darkmode"
console.log("HELLOOOO FROM CONSOLE")

View File

@ -0,0 +1,8 @@
import { ComponentType } from "preact"
export type QuartzComponent<Props> = {
Component: ComponentType<Props>
css?: string,
beforeDOMLoaded?: string,
afterDOMLoaded?: string,
}