the home site for me: also iteration 3 or 4 of my site

feat: enhance title extraction for tag files in OG generation

Changed files
+12 -4
tools
+12 -4
tools/genOG.ts
···
// for each file, get the title tag from the index.html
for (const file of files) {
const index = await Bun.file(`public/${file}`).text();
-
const title = index.match(/<title>(.*?)<\/title>/)![1];
-
if (!title) {
-
console.error(`No title found for ${file}`);
-
continue;
}
console.log("Generating OG for", title);
···
// for each file, get the title tag from the index.html
for (const file of files) {
const index = await Bun.file(`public/${file}`).text();
+
let title: string;
+
if (file.startsWith("tags/")) {
+
const parts = file.split("/");
+
title = `Tag: ${parts[1]}`; // take the next directory as the title
+
} else {
+
const match = index.match(/<title>(.*?)<\/title>/);
+
if (match) {
+
title = match[1];
+
} else {
+
console.error(`No title found for ${file}`);
+
continue;
+
}
}
console.log("Generating OG for", title);