Skip to content

Commit 98a43ec

Browse files
authored
Merge pull request #17 from shrvansudhakara/fix/sort-talks-by-year
Add sorting for talks by year
2 parents c0ad3c8 + 2fd3e13 commit 98a43ec

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/lib/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ export const sortJobsByDate = (jobs: CollectionEntry<'jobs'>[]) => {
3434
return nextEnd - currentEnd || next.data.from - current.data.from;
3535
});
3636
};
37+
38+
export const sortTalksByYear = (talks: CollectionEntry<'talks'>[]) => {
39+
return talks.sort((a, b) => b.data.year - a.data.year);
40+
};

src/pages/index.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Author from '@/components/ui/Author.astro';
66
import { DEFAULT_CONFIGURATION } from '@/lib/constants';
77
import WorkExperience from '@/components/ui/WorkExperience.astro';
88
import Talk from '@/components/ui/Talk.astro';
9-
import { sortJobsByDate } from '@/lib/utils';
9+
import { sortJobsByDate, sortTalksByYear } from '@/lib/utils';
1010
1111
const entry = await getEntry('pages', 'homepage');
1212
@@ -20,6 +20,7 @@ const links = await getCollection('links');
2020
const jobs = await getCollection('jobs');
2121
const sortedJobs = sortJobsByDate(jobs);
2222
const talks = await getCollection('talks');
23+
const sortedTalks = sortTalksByYear(talks);
2324
---
2425

2526
<BaseLayout seo={entry.data.seo}>
@@ -85,7 +86,7 @@ const talks = await getCollection('talks');
8586
<div class="flex flex-col gap-5">
8687
<span class="text-headings">Speaking</span>
8788
<ul class="flex flex-col gap-8">
88-
{talks.map((talk) => (
89+
{sortedTalks.map((talk) => (
8990
<Talk entry={talk} />
9091
))}
9192
</ul>

0 commit comments

Comments
 (0)