// Import this file with 'import * as sg from "#sitegen";' export type ScriptId = string; /** * A filesystem object associated with some ID, * such as a page's route to it's source file. */ export interface FileItem { id: string; file: string; } export interface Section { root: string; } export const userData = render.userData(() => { throw new Error("This function can only be used in a page (static or view)"); }); export interface SitegenRender { scripts: Set; } export function initRender(): SitegenRender { return { scripts: new Set() }; } /** Add a client-side script to the page. */ export function addScript(id: ScriptId | { value: ScriptId }) { userData.get().scripts.add(typeof id === "string" ? id : id.value); } export function wrapDocument({ body, head, inlineCss, scripts, }: { head: string; body: string; inlineCss: string; scripts: string; }) { return `${head}${ inlineCss ? `` : "" }${body}${ scripts ? `` : "" }`; } import * as render from "#engine/render";