oliverdavies.uk/src/pages/talks/index.astro
Oliver Davies 77ed75a699 fix(talks): order future talks in reverse
Show the nearest upcoming talk first.
2023-08-02 23:30:00 +01:00

46 lines
1.2 KiB
Text

---
import ListingPage from "~/components/ListingPage.astro";
import _ from "lodash";
import { getCollection } from "astro:content";
import Markdown from "~/components/Markdown.astro";
const talks = await getCollection("talk");
const talkCount = _(talks)
.flatMap((talk) => talk.data.events)
.size();
const sortedTalks = talks
.map((talk) => {
const slug = `/talks/${talk.slug}`;
return { slug, item: talk };
})
.sort((b, a) => {
const events = [
a.item.data.events[a.item.data.events.length - 1],
b.item.data.events[b.item.data.events.length - 1],
];
const dates = [
new Date(events[0].date).valueOf(),
new Date(events[1].date).valueOf(),
];
if (dates[0] >= today) {
return 1;
}
return dates[0] - dates[1];
});
---
<ListingPage items={sortedTalks} title="Talks and workshops">
<Markdown slot="intro">
<p>
Starting with my first talk in September 2012, I have given {talkCount} presentations
and workshops at various conferences and meetups, in-person and remotely, on
topics including PHP, Drupal, automated testing, Git, CSS, and systems administration.
</p>
</Markdown>
</ListingPage>