From e0e86201e66e5e0be2a215b7e1295a40df726dc5 Mon Sep 17 00:00:00 2001 From: Jean-Marie 'Histausse' Mineau Date: Tue, 21 Apr 2026 21:38:43 +0200 Subject: [PATCH] Sort card by date in summaries --- lib/summary.typ | 7 ++++++- test_template/main.typ | 7 ++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/summary.typ b/lib/summary.typ index 7596b9b..568f5e3 100644 --- a/lib/summary.typ +++ b/lib/summary.typ @@ -130,7 +130,12 @@ lang: "raw-css", ) chtml.summary-card-list(attrs: (class: class-name), { - for summ in summs { + for summ in summs.sorted(key: it => + -(it.document-args.date.day()-1 + 31 * ( + (it.document-args.date.month()-1) + + 12 * it.document-args.date.year() + )) + ) { summ.card } }) diff --git a/test_template/main.typ b/test_template/main.typ index cca7e15..f684e0d 100644 --- a/test_template/main.typ +++ b/test_template/main.typ @@ -164,16 +164,17 @@ thead { caption: [A Big Platypus!] ) +#let perm = (17, 6, 20, 19, 15, 5, 13, 11, 14, 12, 16, 10, 2, 3, 1, 9, 7, 4, 18, 8) #card-list( min-width: 200, - range(1, 21).map(i => + range(20).map(i => summary( url: "http://test.example.com", - title: "Card " + str(i), + title: "Card " + str(perm.at(i)), preview-image: summ.preview-image, author: "Me!", description: lorem(10 * calc.rem(i * 123, 10)), - date: datetime(year: 2000, month: 12, day: i), + date: datetime(year: 2000, month: 12, day: perm.at(i)), ) ) )