This commit is contained in:
Morten Olsen
2025-12-02 22:38:20 +01:00
parent 1693a2620c
commit 06564dff21
117 changed files with 2522 additions and 7180 deletions

View File

@@ -0,0 +1,32 @@
import { getCollection, getEntry } from "astro:content";
class Experiences {
public getAll = async () => {
const collection = await getCollection('experiences');
return collection.sort(
(a, b) => new Date(b.data.startDate).getTime() - new Date(a.data.startDate).getTime(),
);
}
public get = async (id: string) => {
const entry = await getEntry('experiences', id);
if (!entry) {
throw new Error(`Experience ${id} not found`);
}
return entry;
}
public getCurrent = async () => {
const all = await this.getAll();
return all.find((experience) => !experience.data.endDate);
}
public getPrevious = async () => {
const all = await this.getAll();
return all.filter((experience) => experience.data.endDate);
}
}
const experiences = new Experiences();
export { experiences }