summaryrefslogtreecommitdiff
path: root/lib/pages/BlogIndex.mlx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pages/BlogIndex.mlx')
-rw-r--r--lib/pages/BlogIndex.mlx76
1 files changed, 76 insertions, 0 deletions
diff --git a/lib/pages/BlogIndex.mlx b/lib/pages/BlogIndex.mlx
new file mode 100644
index 0000000..3e036aa
--- /dev/null
+++ b/lib/pages/BlogIndex.mlx
@@ -0,0 +1,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 *)