travel metadata

This commit is contained in:
2026-02-08 07:19:01 +00:00
parent 7a2503e556
commit c83e44b5a3
2 changed files with 51 additions and 0 deletions

28
src/travel/index.ts Normal file
View File

@@ -0,0 +1,28 @@
export type TravelMetadata = {
id: number;
continent: string;
country: string;
city: string;
date: string;
};
const travelModules = import.meta.glob<TravelMetadata[]>("./metadata.json", {
eager: true,
import: "default",
});
export const locations = Object.values(travelModules).flat().reverse();
export const locationPhotos: Record<number, string[]> = {};
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, ""));
}

23
src/travel/metadata.json Normal file
View File

@@ -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"
}
]