This commit is contained in:
Morten Olsen
2024-04-19 20:51:52 +02:00
committed by Morten Olsen
parent 98e39a54cc
commit ee37ac9d90
51 changed files with 604 additions and 798 deletions

View File

@@ -1,13 +1,13 @@
import { getCollection } from 'astro:content';
import { getCollection } from 'astro:content'
class Articles {
public find = () => getCollection('articles');
public find = () => getCollection('articles')
public get = async (slug: string) => {
const collection = await this.find();
return collection.find((entry) => entry.slug === slug);
};
const collection = await this.find()
return collection.find((entry) => entry.slug === slug)
}
}
type Article = Exclude<Awaited<ReturnType<Articles['get']>>, undefined>;
type Article = Exclude<Awaited<ReturnType<Articles['get']>>, undefined>
export { Articles, type Article };
export { Articles, type Article }

View File

@@ -1,13 +1,13 @@
import { getCollection } from 'astro:content';
import { getCollection } from 'astro:content'
class References {
public find = () => getCollection('references');
public find = () => getCollection('references')
public get = async (slug: string) => {
const collection = await this.find();
return collection.find((entry) => entry.slug === slug);
};
const collection = await this.find()
return collection.find((entry) => entry.slug === slug)
}
}
type Reference = Exclude<Awaited<ReturnType<References['get']>>, undefined>;
type Reference = Exclude<Awaited<ReturnType<References['get']>>, undefined>
export { References, type Reference };
export { References, type Reference }

View File

@@ -1,5 +1,5 @@
const site = {
theme: '#30E130',
};
theme: '#30E130'
}
export { site };
export { site }

View File

@@ -1,13 +1,13 @@
import { getCollection } from 'astro:content';
import { getCollection } from 'astro:content'
class Skills {
public find = () => getCollection('skills');
public find = () => getCollection('skills')
public get = async (slug: string) => {
const collection = await this.find();
return collection.find((entry) => entry.slug === slug);
};
const collection = await this.find()
return collection.find((entry) => entry.slug === slug)
}
}
type Skill = Exclude<Awaited<ReturnType<Skills['get']>>, undefined>;
type Skill = Exclude<Awaited<ReturnType<Skills['get']>>, undefined>
export { Skills, type Skill };
export { Skills, type Skill }

View File

@@ -1,25 +1,25 @@
import { profile } from '../content/profile/profile.js';
import { type Article, Articles } from './data.articles.js';
import { References } from './data.references.ts';
import { site } from './data.site.ts';
import { Skills } from './data.skills.ts';
import { getJsonLDResume, getJsonResume } from './data.utils.js';
import { Work, type WorkItem } from './data.work.js';
import { profile } from '../content/profile/profile.js'
import { type Article, Articles } from './data.articles.js'
import { References } from './data.references.ts'
import { site } from './data.site.ts'
import { Skills } from './data.skills.ts'
import { getJsonLDResume, getJsonResume } from './data.utils.js'
import { Work, type WorkItem } from './data.work.js'
class Data {
public articles = new Articles();
public work = new Work();
public references = new References();
public skills = new Skills();
public profile = profile;
public site = site;
public articles = new Articles()
public work = new Work()
public references = new References()
public skills = new Skills()
public profile = profile
public site = site
public getJsonResume = getJsonResume.bind(null, this);
public getJsonLDResume = getJsonLDResume.bind(null, this);
public getJsonResume = getJsonResume.bind(null, this)
public getJsonLDResume = getJsonLDResume.bind(null, this)
}
const data = new Data();
const data = new Data()
type Profile = typeof profile;
export type { Article, Profile, WorkItem };
export { data, Data };
type Profile = typeof profile
export type { Article, Profile, WorkItem }
export { data, Data }

View File

@@ -1,15 +1,15 @@
import type { ResumeSchema } from '@/types/resume-schema.js';
import type { ResumeSchema } from '@/types/resume-schema.js'
import type { Article, Data } from './data';
import type { Article, Data } from './data'
const getJsonResume = async (data: Data) => {
const profile = data.profile;
const profile = data.profile
const resume = {
basics: profile.basics,
} satisfies ResumeSchema;
basics: profile.basics
} satisfies ResumeSchema
return resume;
};
return resume
}
const getArticleJsonLD = async (data: Data, article: Article) => {
const jsonld = {
@@ -23,16 +23,16 @@ const getArticleJsonLD = async (data: Data, article: Article) => {
author: {
'@type': 'Person',
name: data.profile.basics.name,
url: data.profile.basics.url,
},
};
return jsonld;
};
url: data.profile.basics.url
}
}
return jsonld
}
const getJsonLDResume = async (data: Data) => {
const work = await data.work.find();
const currentWork = work.find((w) => !w.data.endDate);
const otherWork = work.filter((w) => w !== currentWork);
const work = await data.work.find()
const currentWork = work.find((w) => !w.data.endDate)
const otherWork = work.filter((w) => w !== currentWork)
const jsonld = {
'@context': 'https://schema.org',
@@ -47,24 +47,24 @@ const getJsonLDResume = async (data: Data) => {
'@type': 'ContactPoint',
contactType: profile.network.toLowerCase(),
identifier: profile.username,
url: profile.url,
url: profile.url
})),
address: {
'@type': 'PostalAddress',
addressLocality: data.profile.basics.location.city,
addressRegion: data.profile.basics.location.region,
addressCountry: data.profile.basics.location.countryCode,
addressCountry: data.profile.basics.location.countryCode
},
sameAs: data.profile.basics.profiles.map((profile) => profile.url),
hasOccupation: currentWork && {
'@type': 'EmployeeRole',
roleName: currentWork.data.position,
startDate: currentWork.data.startDate.toISOString(),
startDate: currentWork.data.startDate.toISOString()
},
worksFor: currentWork && {
'@type': 'Organization',
name: currentWork?.data.name,
sameAs: currentWork?.data.url,
sameAs: currentWork?.data.url
},
alumniOf: otherWork.map((w) => ({
'@type': 'Organization',
@@ -76,14 +76,14 @@ const getJsonLDResume = async (data: Data) => {
'@type': 'EmployeeRole',
roleName: w.data.position,
startDate: w.data.startDate.toISOString(),
endDate: w.data.endDate?.toISOString(),
endDate: w.data.endDate?.toISOString()
},
sameAs: '#me',
},
})),
};
sameAs: '#me'
}
}))
}
return jsonld;
};
return jsonld
}
export { getJsonResume, getJsonLDResume, getArticleJsonLD };
export { getJsonResume, getJsonLDResume, getArticleJsonLD }

View File

@@ -1,12 +1,12 @@
import { getCollection } from 'astro:content';
import { getCollection } from 'astro:content'
class Work {
public find = () => getCollection('work');
public find = () => getCollection('work')
public get = async (slug: string) => {
const collection = await this.find();
return collection.find((entry) => entry.slug === slug);
};
const collection = await this.find()
return collection.find((entry) => entry.slug === slug)
}
}
type WorkItem = Exclude<Awaited<ReturnType<Work['get']>>, undefined>;
export { Work, type WorkItem };
type WorkItem = Exclude<Awaited<ReturnType<Work['get']>>, undefined>
export { Work, type WorkItem }