"server side rendering" is a misleading term since it implies there is a server. that isn't neccecarily the case here, since it supports running in the browser. I think "clover engine" is cute, short for "clover html rendering engine". Instead of "server side rendering", it's just rendering. This commit makes things a lot more concise, such as `ssr.ssrAsync` being renamed to `render.async` to play nicely with namespaced imports. `getCurrentRender` and `setCurrentRender` are just `current` and `setCurrent`, and the addon interface has been redesigned to force symbols with a wrapping helper.
33 lines
814 B
TypeScript
33 lines
814 B
TypeScript
// 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<SitegenRender>(() => {
|
|
throw new Error("This function can only be used in a page (static or view)");
|
|
});
|
|
|
|
export interface SitegenRender {
|
|
scripts: Set<string>;
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
import * as render from "#engine/render";
|