From 96d3069ed12a6c7c3b3d5483a42cc75c19676df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Fri, 17 Nov 2023 12:32:00 +0100 Subject: [PATCH] List three latest articles on index --- src/task.ml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/task.ml b/src/task.ml index e1f9fc0..18a3b2f 100644 --- a/src/task.ml +++ b/src/task.ml @@ -99,4 +99,11 @@ let generate_contact target = let generate_index target = let* articles = articles in + let rec take n xs = + match n, xs with + | 0, _ | _, [] -> [] + | _, x :: xs -> x :: take (pred n) xs + in + let open Build in + let articles = articles >>^ take 3 in with_layout (module Model.Articles) articles "pages/index.md" (index_html target)