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();