refactor: update project data type
- add order property to set explicit ordering on projects page - make project link optional as not all projects have an accessible link
This commit is contained in:
@@ -105,17 +105,12 @@ export async function getPostsByTag(
|
||||
|
||||
export async function getAllProjects(): Promise<CollectionEntry<'projects'>[]> {
|
||||
const projects = await getCollection('projects')
|
||||
return projects
|
||||
.sort((a, b) => (b.data.startDate?.valueOf() ?? 0) - (a.data.startDate?.valueOf() ?? 0))
|
||||
return projects.sort((a, b) => (a.data.order ?? Infinity) - (b.data.order ?? Infinity))
|
||||
}
|
||||
|
||||
const FEATURED_PROJECT_IDS = ['homelab', 'chitai', 'cue', 'portfolio']
|
||||
|
||||
export async function getFeaturedProjects(): Promise<CollectionEntry<'projects'>[]> {
|
||||
const projects = await getAllProjects()
|
||||
return FEATURED_PROJECT_IDS
|
||||
.map(id => projects.find(p => p.id === id))
|
||||
.filter((p): p is CollectionEntry<'projects'> => p !== undefined)
|
||||
return projects.slice(0, 4)
|
||||
}
|
||||
|
||||
export async function getProjectsFeaturedTags(maxCount: number): Promise<string[]> {
|
||||
|
||||
Reference in New Issue
Block a user