blob: 3e036aa6985560f8d4de4c7608856a6b1758caf8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
open Shared
let header ~title () = <header><h1>title</h1></header>
let page =
<html>
<body>
<header title="Hello, world!" /> <div>(React.string "Some content goes here")</div>
</body>
</html>
;;
module Layout = struct
let[@react.component] make ~children =
<html>
<head>
<title>(React.string "Bloody Shovel 5")</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charSet="UTF-8" />
</head>
<body>children</body>
</html>
;;
end
module PostPreviews = struct
let[@react.component] make ~(conn : Query.conn) =
let posts =
match Query.get_poasts () conn with
| Error _err -> []
| Ok posts -> posts
in
let tests = "This is 'a 'weird <thingy>" in
<div>
(match posts with
| [] -> React.string "No posts"
| posts ->
let ps =
posts
|> List.map (fun (p : Query.post_summary) ->
Logs.info (fun d -> d "poast %s\n" p.title);
<h1>(React.string p.title)</h1>)
in
let pp = React.string tests :: ps in
pp |> Array.of_list |> React.array)
</div>
;;
end
let[@react.component] make (conn : Query.conn) =
<Layout>
<div className="min-h-screen bg-gray-50">
<Navbar />
<main className="container mx-auto px-4 py-8">
<SiteTitle />
<div className="max-w-4xl mx-auto space-y-12"><PostPreviews conn /></div>
</main>
</div>
</Layout>
;;
(* let[@react.component] make (conn : Query.conn) = *)
(* let posts = *)
(* match Query.get_poasts () conn with *)
(* | Error _err -> [] *)
(* | Ok posts -> posts *)
(* in *)
(* <div> *)
(* (match posts with *)
(* | [] -> React.string "No posts" *)
(* | hd :: _tl -> React.string hd.title) *)
(* </div> *)
(* ;; *)
(* # formatter = {command = "ocamlformat-mlx", args = ["-", "--impl"]} *)
(* List.map (fun _p -> <p>(React.string "wtf")</p>) posts |> React.list *)
|