Files for my website bwc9876.dev
at main 33 lines 782 B view raw
1--- 2import ProjectCard from "./ProjectCard.astro"; 3import { getCollection } from "astro:content"; 4 5export interface Props { 6 limitTo?: number; 7} 8 9const projectEntries = await getCollection("projects"); 10let entries = projectEntries.sort((a, b) => { 11 const [yearA, yearB] = [a.data.timespan.from, b.data.timespan.from]; 12 const [intA, intB] = [a.data.internalSort ?? 0, b.data.internalSort ?? 0]; 13 const yearSort = yearB - yearA; 14 return yearSort === 0 ? intB - intA : yearSort; 15}); 16 17const { limitTo } = Astro.props; 18if (limitTo) { 19 entries = entries.slice(0, limitTo); 20} 21--- 22 23<div> 24 {entries.map((p) => <ProjectCard project={p} />)} 25</div> 26 27<style> 28 div { 29 display: grid; 30 gap: var(--2); 31 grid-template-columns: repeat(auto-fit, minmax(var(--14), 1fr)); 32 } 33</style>