mirror of
https://github.com/hex248/ob248.com.git
synced 2026-02-09 11:13:03 +00:00
travel metadata
This commit is contained in:
28
src/travel/index.ts
Normal file
28
src/travel/index.ts
Normal 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
23
src/travel/metadata.json
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user