refactor: move gallery entries into seperate data file
All checks were successful
Deploy on push / deploy (push) Has been skipped

This commit is contained in:
2026-03-22 19:23:33 -07:00
parent 57e3172e74
commit 2756bf754e
3 changed files with 233 additions and 0 deletions

170
data/meals.json Normal file
View File

@@ -0,0 +1,170 @@
[
{
"id": "01",
"position": "left center",
"title": "sf on $10",
"description": "this was so not real i can't believe technically u paid for our first meal back. calmluh 3 years after. first hang !!!! pork buns were yummy 7/10"
},
{
"id": "02",
"title": "honey butter chicken",
"description": "the first thing you cooked for me ! so yum 10/10"
},
{
"id": "03",
"position": "top center",
"title": "aloha fresh",
"description": "we fucking love this place 10/10 i love poke i should have never quit pokehouse"
},
{
"id": "04",
"title": "mad yolks",
"description": "for our santa cruz hang! u in my city now. so so good but lwk so so tax 9/10"
},
{
"id": "05",
"position": "top center",
"title": "sizzling lunch",
"description": "better than pepper lunch. server was being a little bitchy but i would be too if i was the only one working the front. 8/10"
},
{
"id": "06",
"title": "braised pork belly",
"description": "omfg this is my favorite thing uve made 100/10"
},
{
"id": "07",
"title": "sushi w/ claire!",
"description": "and then we played bananagrams. sushi 8/10 thanks for paying mommy"
},
{
"id": "08",
"title": "myungrang hot dog",
"description": "main street tino nothing special 7/10"
},
{
"id": "09",
"title": "liangs village",
"description": "my peoples food. 9/10"
},
{
"id": "10",
"title": "cabonara",
"description": "insane safeway hang 9/10"
},
{
"id": "11",
"title": "heytea",
"description": "this fuckass blue drink"
},
{
"id": "12",
"title": "sparcos",
"description": "one of many.. 100/10"
},
{
"id": "13",
"title": "noahs bagels",
"description": "this is the plaza where i used to go to all the time before school 9/10"
},
{
"id": "14",
"title": "homeroom",
"description": "mac and cheese was gas. 10/10. you know its my fav comfort food. free the girl crying in the corner tho"
},
{
"id": "15",
"title": "sparcos x2",
"description": "spartan tacos"
},
{
"id": "16",
"title": "sparcos x3",
"description": "okay damn no way we got this b2b"
},
{
"id": "17",
"title": "aloha fresh",
"description": "this is lowkey the spot poke always hits so fucking good"
},
{
"id": "18",
"title": "house of bagels",
"description": "hobags ughgmmfmfm im such a fucking ho for hobags 100/10"
},
{
"id": "19",
"title": "toro sushi",
"description": "carmel by the sea! we love sushi but tax 8/10"
},
{
"id": "20",
"title": "sul and beans",
"description": "sweet treat -> claire dropping the most insane piece of information ever -> hti the yap"
},
{
"id": "21",
"title": "highland hand pulled noodles",
"description": "so good and soooo filling 10/10. also my peoples food."
},
{
"id": "22",
"title": "bloom",
"description": "even when its rich white people breakfast im getting salmon nox 10/10"
},
{
"id": "23",
"title": "happy donuts",
"description": "1k cal meal 0 protein 10/10"
},
{
"id": "24",
"title": "marugame",
"description": "i dont want to talk about this. 9/10"
},
{
"id": "25",
"title": "siam station!",
"description": "i can't believe u didnt eat ur leftovers. 10/10"
},
{
"id": "26",
"title": "muukata 6395",
"description": "for my birthday!! i love eating meat and i love you so perfect combination 1000/10"
},
{
"id": "27",
"title": "bambu",
"description": "why was the store so nice. i wonder about the 4 sisters"
},
{
"id": "28",
"title": "porridge at julias",
"description": "her boyfriend is so not real hes so stupid and funny. porridge was gas too i love eating free at julias 10/10"
},
{
"id": "29",
"title": "sparcos x4",
"description": "spartan tacos. i was moody lol."
},
{
"id": "30",
"title": "wonton udon",
"description": "i helped wrap the wontons w/ u !!! super fun and super yummy 10/10"
},
{
"id": "31",
"title": "steak dinna for vday",
"description": "marry me? yes. 100/10 best valentines day ever"
},
{
"id": "32",
"title": "poke house",
"description": "poke house 3 years later 9/10 but +1 point bc its basically free"
},
{
"id": "33",
"title": "hey tea",
"description": "mochi yinje black milk tea ts was actually so buss 10/10 only boba i've ever wanted to get again myself"
}
]

View File

@@ -33,6 +33,7 @@
<!-- Thumbnail --> <!-- Thumbnail -->
<section id="thumbnails"> <section id="thumbnails">
<!-- Generated gallery items: start -->
<article> <article>
<a class="thumbnail" href="images/fulls/01.jpg" data-position="left center"><img src="images/thumbs/01.jpg" alt="" /></a> <a class="thumbnail" href="images/fulls/01.jpg" data-position="left center"><img src="images/thumbs/01.jpg" alt="" /></a>
<h2>sf on $10</h2> <h2>sf on $10</h2>
@@ -198,6 +199,7 @@
<h2>hey tea</h2> <h2>hey tea</h2>
<p>mochi yinje black milk tea ts was actually so buss 10/10 only boba i've ever wanted to get again myself</p> <p>mochi yinje black milk tea ts was actually so buss 10/10 only boba i've ever wanted to get again myself</p>
</article> </article>
<!-- Generated gallery items: end -->
</section> </section>
<!-- Footer --> <!-- Footer -->

61
scripts/render-gallery.js Normal file
View File

@@ -0,0 +1,61 @@
const fs = require("fs");
const path = require("path");
const repoRoot = path.resolve(__dirname, "..");
const dataPath = path.join(repoRoot, "data", "meals.json");
const indexPath = path.join(repoRoot, "index.html");
const startMarker = "<!-- Generated gallery items: start -->";
const endMarker = "<!-- Generated gallery items: end -->";
function escapeHtml(value) {
return value
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/\"/g, "&quot;");
}
function renderArticle(entry, eol) {
const attrs = [`class="thumbnail"`, `href="images/fulls/${entry.id}.jpg"`];
if (entry.position) {
attrs.push(`data-position="${escapeHtml(entry.position)}"`);
}
return [
"\t\t\t\t<article>",
`\t\t\t\t\t<a ${attrs.join(" ")}><img src="images/thumbs/${entry.id}.jpg" alt="" /></a>`,
`\t\t\t\t\t<h2>${escapeHtml(entry.title)}</h2>`,
`\t\t\t\t\t<p>${escapeHtml(entry.description)}</p>`,
"\t\t\t\t</article>",
].join(eol);
}
function renderGallery(entries, eol) {
return entries.map((entry) => renderArticle(entry, eol)).join(eol);
}
function main() {
const entries = JSON.parse(fs.readFileSync(dataPath, "utf8"));
const indexHtml = fs.readFileSync(indexPath, "utf8");
const eol = indexHtml.includes("\r\n") ? "\r\n" : "\n";
const galleryMarkup = renderGallery(entries, eol);
const replacement = [
`\t\t\t\t${startMarker}`,
galleryMarkup,
`\t\t\t\t${endMarker}`,
].join(eol);
const markerPattern = new RegExp(
`^[\\t ]*${startMarker}[\\s\\S]*?^[\\t ]*${endMarker}`,
"m"
);
if (!markerPattern.test(indexHtml)) {
throw new Error("Could not find gallery markers in index.html");
}
fs.writeFileSync(indexPath, indexHtml.replace(markerPattern, replacement));
}
main();