summaryrefslogtreecommitdiff
path: root/cgithub/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'cgithub/scripts')
-rw-r--r--cgithub/scripts/build.ts20
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.