diff options
author | polwex <polwex@sortug.com> | 2025-06-27 16:34:09 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-06-27 16:34:09 +0700 |
commit | 645e815ebe11dbb86781c3eb645d3d67cd62cf7c (patch) | |
tree | 347b03391a5245de8a43198c9646719c2e892373 /lib/pages/BlogIndex.mlx | |
parent | 8be9a806a93b02eada372f3993c34bc6b2f26fea (diff) |
nice nice. lsp still doesnt work tho
Diffstat (limited to 'lib/pages/BlogIndex.mlx')
-rw-r--r-- | lib/pages/BlogIndex.mlx | 76 |
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 *) |