diff options
| author | Joe Mou <dev@mou.fo> | 2026-09-04 21:26:21 -0400 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-09-04 21:49:59 -0400 |
| commit | 53ac3bc511a45e4e2e3f234a8b8dcf853b0c38d9 (patch) | |
| tree | d887da14050b199aca617a4f46d52763a2da7073 /cgithub/scripts/build.ts | |
| parent | 5bfe8b345d2ee92111a2363321a248adb4f5195a (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/scripts/build.ts')
| -rw-r--r-- | cgithub/scripts/build.ts | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/cgithub/scripts/build.ts b/cgithub/scripts/build.ts index 76d88a0..4908532 100644 --- a/cgithub/scripts/build.ts +++ b/cgithub/scripts/build.ts @@ -14,10 +14,22 @@ const root = path.join(import.meta.dirname, ".."); const viewsDir = path.join(root, "views"); const eta = new Eta({ views: viewsDir }); -const names = fs - .readdirSync(viewsDir) - .filter((name) => name.endsWith(".eta")) - .sort(); +// Names are the templates' paths under views/, e.g. "layouts/base.eta", which +// is how the templates address each other (see src/worker.ts). +function templateNames(dir: string, prefix = ""): string[] { + const names: string[] = []; + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const name = prefix + entry.name; + if (entry.isDirectory()) { + names.push(...templateNames(path.join(dir, entry.name), `${name}/`)); + } else if (entry.name.endsWith(".eta")) { + names.push(name); + } + } + return names.sort(); +} + +const names = templateNames(viewsDir); let out = `// @ts-nocheck // Generated by scripts/build.ts -- do not edit. |
