make serve function

This commit is contained in:
2020-08-28 18:24:58 +02:00
parent 7a711e8286
commit 909f637722
2 changed files with 22 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ let spec =
" Consider all remaining arguments as input file names.";
]
(** Utitilies *)
let with_open_in fn f =
let ic = open_in fn in
match f ic with
@@ -34,6 +34,8 @@ let read_metadata ic =
| _ -> lst
in go []
(** Functions for processing an individual post *)
let format_post ~title ~tags ~date ~contents =
String.concat "" [
{|<!DOCTYPE html>
@@ -69,6 +71,7 @@ let format_post ~title ~tags ~date ~contents =
</body>|}]
(* convert contents from [ic] to a post webpage, output to [oc] *)
let process ic oc =
let metadata = read_metadata ic in
let lookup_metadata k =