From 0550bb1227cf76738332efef9f94f19b34f325c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Tue, 14 Nov 2023 11:44:51 +0100 Subject: [PATCH] Sort articles --- src/model.ml | 6 ++++++ src/task.ml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/model.ml b/src/model.ml index a07721b..53454d3 100644 --- a/src/model.ml +++ b/src/model.ml @@ -67,6 +67,12 @@ module Articles = struct let make path article = (path, article) + let sort articles = + List.sort + (fun (_, a) (_, b) -> + ~-(Date.compare a.Article.date b.Article.date)) + articles + let inject (type a) (module D : Key_value.DESCRIBABLE with type t = a) articles = D.[ "articles", diff --git a/src/task.ml b/src/task.ml index 21b2c97..5952f1f 100644 --- a/src/task.ml +++ b/src/task.ml @@ -76,7 +76,7 @@ let articles = Metaformat.read_file_with_metadata (module Model.Article) path >>^ fun (meta, _data) -> (Model.article_path path, meta)) - (fun articles () -> articles) + (fun articles () -> Model.Articles.sort articles) let generate_archive target = let* articles = articles in