From 6ce909056933e59634e4d6b538a8316e558f35f7 Mon Sep 17 00:00:00 2001 From: Norbert Melzer Date: Sat, 29 Mar 2025 15:53:16 +0100 Subject: [PATCH] docs for sorter --- src/scripts/sorter.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/scripts/sorter.ts b/src/scripts/sorter.ts index 490698f..d45e345 100644 --- a/src/scripts/sorter.ts +++ b/src/scripts/sorter.ts @@ -9,5 +9,14 @@ export type DateSortable = { }; }; +/** + * Can be used for any `ContentCollection` that has a `data.date` field to sort + * by it. + * + * @param a first item to compare + * @param b second item to compare + * @returns positive number if `a` is older than `b`, negative number if `a` is + * newer than `b` + */ export const byDate = (a: DateSortable, b: DateSortable): number => b.data.date.getTime() - a.data.date.getTime(); -- 2.51.2