diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2023-10-10 00:02:23 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2023-10-10 00:02:23 +0200 |
commit | b43c2ebbf36277df54a7954741c7a7399afc0130 (patch) | |
tree | 86614f17de3dcc2a8b3246dbdd5118bec8aa40a7 /src | |
parent | c65bf6c1e2af514da5322376a7602ea3be80cda1 (diff) |
html, atom: order by date
Diffstat (limited to 'src')
-rw-r--r-- | src/atom.scm | 3 | ||||
-rw-r--r-- | src/dates.scm | 6 | ||||
-rw-r--r-- | src/html.scm | 11 |
3 files changed, 17 insertions, 3 deletions
diff --git a/src/atom.scm b/src/atom.scm index ca2a225..9f363f7 100644 --- a/src/atom.scm +++ b/src/atom.scm @@ -78,7 +78,8 @@ (find-newest (map entry-updated posts)) '())) (append-entry! (partial append-feed-entry! f))) - (for-each append-entry! posts) + (for-each append-entry! + (sort posts date>?)) f)) diff --git a/src/dates.scm b/src/dates.scm index 2bbb977..e9c9b0c 100644 --- a/src/dates.scm +++ b/src/dates.scm @@ -5,7 +5,8 @@ date->string/RFC3339 unix-date newest - find-newest)) + find-newest + date>?)) (define (string/ISO->date string) (string->date string "~Y-~m-~d")) @@ -17,4 +18,7 @@ (define (newest a b) (if (time>? (date->time-utc a) (date->time-utc b)) a b)) +(define (date>? a b) + (time>? (date->time-utc a) (date->time-utc b))) + (define (find-newest dates) (reduce newest unix-date dates)) diff --git a/src/html.scm b/src/html.scm index 707ef2f..a6bdd13 100644 --- a/src/html.scm +++ b/src/html.scm @@ -72,7 +72,16 @@ (styles '()) (scripts '()) #:allow-other-keys) - (make-index title short-description long-description uri atom-feed-uri author posts styles scripts)) + (make-index + title + short-description + long-description + uri + atom-feed-uri + author + (sort posts date>?) + styles + scripts)) (define* (post #:key (id #f) |