summaryrefslogtreecommitdiff
path: root/cgithub/src
diff options
context:
space:
mode:
authorJoe Mou <dev@mou.fo>2026-09-04 21:26:21 -0400
committerJoe Mou <dev@mou.fo>2026-09-04 21:49:59 -0400
commit53ac3bc511a45e4e2e3f234a8b8dcf853b0c38d9 (patch)
treed887da14050b199aca617a4f46d52763a2da7073 /cgithub/src
parent5bfe8b345d2ee92111a2363321a248adb4f5195a (diff)
Split the page shell out of the repository layout
layout.eta was two things at once: the HTML shell every page needs and the repository chrome around it. owner.eta, being the one page that is not about a repository, could use neither and carried its own copy of the shell, which had drifted -- its footer named no build commit and did not link to the original page on GitHub. The shell moves to views/layouts/base.eta, taking its title and any deferred scripts as layout data, and the chrome to views/layouts/repo.eta, a layout over it that adds the clone commands, nav, search box, and the "/" shortcut that focuses it. Repository pages point at repo.eta and render as before; owner.eta uses base.eta directly and so gains the footer it was missing. Templates now live in more than one directory, so scripts/build.ts walks views/ recursively and keys each template by its path underneath it. Names crossing a directory are written from the views root ("/layouts/base.eta"), the one form both Eta's filesystem resolver and the precompiled resolver in worker.ts agree on; siblings stay relative. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ba5p88cWtCq42vf3uweweL
Diffstat (limited to 'cgithub/src')
-rw-r--r--cgithub/src/app.ts2
-rw-r--r--cgithub/src/worker.ts5
2 files changed, 5 insertions, 2 deletions
diff --git a/cgithub/src/app.ts b/cgithub/src/app.ts
index 2fa5832..a040aaa 100644
--- a/cgithub/src/app.ts
+++ b/cgithub/src/app.ts
@@ -39,7 +39,7 @@ export function createApp(eta: Eta) {
const app = new Hono();
app.use(async (c, next) => {
- // Include render data for layout.eta.
+ // Include render data for views/layouts/base.eta.
c.setRenderer((template, data) =>
c.html(eta.render(template, { ...data, githubUrl: githubUrlFor(c), buildCommit })),
);
diff --git a/cgithub/src/worker.ts b/cgithub/src/worker.ts
index 7bf9100..e59c690 100644
--- a/cgithub/src/worker.ts
+++ b/cgithub/src/worker.ts
@@ -9,8 +9,11 @@ import { views } from "./views.generated.ts";
// cache: true, Eta serves them from the cache and never compiles.
const eta = new Eta({ cache: true });
+// Templates name each other as siblings ("./_tree") or from the views root
+// ("/layouts/base.eta"); either way the name is the path under views/ that
+// scripts/build.ts keyed the template by.
eta.resolvePath = (templatePath: string) => {
- let name = templatePath.replace(/^\.\//, "");
+ let name = templatePath.replace(/^\.?\//, "");
if (!name.endsWith(".eta")) name += ".eta";
return name;
};