// 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 SitegenRender { scripts: Set; } export function initRender(): SitegenRender { return { scripts: new Set(), }; } export function getRender() { return ssr.getUserData("sitegen", () => { throw new Error( "This function can only be used in a page (static or view)", ); }); } export function inRender() { return "sitegen" in ssr.getCurrentRender(); } /** Add a client-side script to the page. */ export function addScript(id: ScriptId | { value: ScriptId }) { getRender().scripts.add(typeof id === "string" ? id : id.value); } export interface Section { root: string; } import * as ssr from "../engine/ssr.ts";