diff --git a/cli.ts b/cli.ts
index dfa4420..b9252f7 100644
--- a/cli.ts
+++ b/cli.ts
@@ -1,6 +1,23 @@
-import { pages } from "./content/pages.js"
+import * as fs from "node:fs";
+import * as posix from "node:path/posix";
import { prettify, htmlDocument } from "antihtml";
-import * as fs from "node:fs"
+import { pages } from "./content/pages.js";
+import type { Page } from "./content/types.js";
+import { resolveRefs } from "./utils/resolve-refs.js";
+
+function pageToHtml(page: Page) {
+ if (!page.ref.startsWith("/")) {
+ throw new Error(`ref "${page.ref}" for "${page.title}" is not absolute.`);
+ }
+ return htmlDocument(
+ prettify(
+ resolveRefs(
+ page.content,
+ posix.dirname(page.ref),
+ )
+ )
+ )
+}
const outDir = "build/web";
if (!fs.existsSync(outDir)) {
@@ -15,8 +32,8 @@ for (const page of pages) {
fs.mkdirSync(dir);
}
}
- console.log(`writing ${outDir}/${page.ref}`);
- fs.writeFileSync(`${outDir}/${page.ref}`, htmlDocument(prettify(page.content)));
+ console.log(`writing ${outDir}${page.ref}`);
+ fs.writeFileSync(`${outDir}${page.ref}`, pageToHtml(page));
}
console.log(`writing ${outDir}/style.css`);
diff --git a/content/bases.tsx b/content/bases.tsx
index cf9f3ae..9e81ea7 100644
--- a/content/bases.tsx
+++ b/content/bases.tsx
@@ -9,12 +9,12 @@ export function BasePage(props: BaseProps) {
{props.title}
-
+
{props.children}
diff --git a/content/index.tsx b/content/index.tsx
index e4cef5f..1b01c06 100644
--- a/content/index.tsx
+++ b/content/index.tsx
@@ -5,7 +5,7 @@ import { updates } from "./updates.js"
const title = "Hornwitser's Site";
export const index = {
title,
- ref: "index.html",
+ ref: "/index.html",
content:
@@ -21,13 +21,13 @@ export const index = {
I'm a red dragon that mostly dabble in hobby programming and the occasional artwork.
-
+
Projects
,
diff --git a/content/projects.tsx b/content/projects.tsx
index a5f0493..43b12b5 100644
--- a/content/projects.tsx
+++ b/content/projects.tsx
@@ -4,23 +4,23 @@ import type { Page } from "./types.js";
export const projects: Page[] = [
{
title: "Buddhabrot renderer",
- ref: "projects/buddhabrot.html",
+ ref: "/projects/buddhabrot.html",
},
{
title: "Wooden Drawing Board",
- ref: "projects/drafting-board.html",
+ ref: "/projects/drafting-board.html",
},
{
title: "Flying Hornwitser Paper Craft",
- ref: "projects/paper-hornwitser.html",
+ ref: "/projects/paper-hornwitser.html",
},
{
title: "Prototype Soren Plush",
- ref: "projects/plush-soren.html",
+ ref: "/projects/plush-soren.html",
},
{
title: "Blender to CSS export script",
- ref: "projects/blender-css.html",
+ ref: "/projects/blender-css.html",
},
].map(page => ({
title: page.title,
@@ -35,12 +35,12 @@ export const projects: Page[] = [
const title = "Hornwitser's Projects";
export const projectsIndex: Page = {
title,
- ref: "projects.html",
+ ref: "/projects.html",
content:
{title}
diff --git a/content/updates.tsx b/content/updates.tsx
index 6c5d095..935af7e 100644
--- a/content/updates.tsx
+++ b/content/updates.tsx
@@ -5,7 +5,7 @@ export const updates: Page[] = [
{
published: "2025-xx-xx",
title: "Website Launch",
- ref: "updates/site-launch.html",
+ ref: "/updates/site-launch.html",
}
].map(page => ({
title: page.title,
@@ -20,12 +20,12 @@ export const updates: Page[] = [
const title = "Website Updates";
export const updatesIndex: Page = {
title,
- ref: "updates.html",
+ ref: "/updates.html",
content:
{title}