diff options
author | polwex <polwex@sortug.com> | 2025-07-18 19:07:53 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-07-18 19:07:53 +0700 |
commit | b41c9ec4a2cf26cea263e24145e23b7165cdd9f1 (patch) | |
tree | 8af04dc8e4859c8fc59a419cb990f9a96a5bccd9 | |
parent | e1bc08ed2b35a9b9faf76fab8316aec4224782cb (diff) |
-rw-r--r-- | dune | 6 | ||||
-rw-r--r-- | lib/pages/BlogIndex.mlx | 2 | ||||
-rw-r--r-- | lib/router.ml | 5 |
3 files changed, 10 insertions, 3 deletions
@@ -0,0 +1,6 @@ +(rule + (target styles.css) + (deps + (glob_files_rec assets/*)) + (action + (bash "sh ~/code/ocaml/bs5/tailwind.sh"))) diff --git a/lib/pages/BlogIndex.mlx b/lib/pages/BlogIndex.mlx index 7f13bed..a7a680f 100644 --- a/lib/pages/BlogIndex.mlx +++ b/lib/pages/BlogIndex.mlx @@ -15,7 +15,7 @@ module Layout = struct <html> <head> <title>(React.string "Bloody Shovel 5")</title> - <link href="/styles.css" rel="stylesheet" /> + <link href="/assets/styles.css" rel="stylesheet" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta charSet="UTF-8" /> </head> diff --git a/lib/router.ml b/lib/router.ml index c3b4af2..ee789c6 100644 --- a/lib/router.ml +++ b/lib/router.ml @@ -27,8 +27,9 @@ let static (path : Parts.t) (_db : Handler.pool) (_req : Request.t) : (Response.t, Caqti_error.t) result = let pat = Parts.wildcard_match path in - Logs.info (fun d -> d "static path %S\n" pat); - match Body.sendfile pat with + let asset_path = "assets/" ^ pat in + Logs.info (fun d -> d "static path %S\n" asset_path); + match Body.sendfile asset_path with | Error _ -> Ok (Response.create `Not_found) | Ok body -> (match Body.to_string body with |