From c83e44b5a3134885386631d3a5bab9a857f0943b Mon Sep 17 00:00:00 2001 From: Oliver Bryan Date: Sun, 8 Feb 2026 07:19:01 +0000 Subject: [PATCH] travel metadata --- src/travel/index.ts | 28 ++++++++++++++++++++++++++++ src/travel/metadata.json | 23 +++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/travel/index.ts create mode 100644 src/travel/metadata.json diff --git a/src/travel/index.ts b/src/travel/index.ts new file mode 100644 index 00000000..adfba5cc --- /dev/null +++ b/src/travel/index.ts @@ -0,0 +1,28 @@ +export type TravelMetadata = { + id: number; + continent: string; + country: string; + city: string; + date: string; +}; + +const travelModules = import.meta.glob("./metadata.json", { + eager: true, + import: "default", +}); + +export const locations = Object.values(travelModules).flat().reverse(); + +export const locationPhotos: Record = {}; + +const allTravelPhotoPaths = Object.keys( + import.meta.glob("../../public/travel/**/*.{jpg,jpeg,png,webp,avif}"), +); + +for (const location of locations) { + const locationFolder = `../../public/travel/${location.city} ${location.country} ${location.date}/`; + + locationPhotos[location.id] = allTravelPhotoPaths + .filter((path) => path.startsWith(locationFolder)) + .map((path) => path.replace(locationFolder, "")); +} diff --git a/src/travel/metadata.json b/src/travel/metadata.json new file mode 100644 index 00000000..d7d4306b --- /dev/null +++ b/src/travel/metadata.json @@ -0,0 +1,23 @@ +[ + { + "id": 1, + "continent": "Europe", + "country": "Italy", + "city": "Bologna", + "date": "June" + }, + { + "id": 2, + "continent": "Europe", + "country": "Hungary", + "city": "Budapest", + "date": "September" + }, + { + "id": 3, + "continent": "Europe", + "country": "Spain", + "city": "Barcelona", + "date": "October" + } +]