Skip to content

Commit

Permalink
Upgrade binary to take advantage of Static
Browse files Browse the repository at this point in the history
  • Loading branch information
gr-im committed Aug 13, 2024
1 parent 7a01843 commit 750ffc4
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions lib/rule.ml
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
open Yocaml

let pipe_content path =
let open Task in
lift ~has_dynamic_dependencies:false (fun x -> (x, ()))
>>> second (Pipeline.read_file path)
>>> lift ~has_dynamic_dependencies:false (fun (x, y) -> x ^ "\n" ^ y)

let track_binary = Pipeline.track_file (Path.rel [ Sys.argv.(0) ])

let css ~target =
let target = Resolver.css ~target in
Action.write_static_file target
(let open Task in
Pipeline.read_file (Path.rel [ "css"; "reset.css" ])
>>> pipe_content (Path.rel [ "css"; "style.css" ]))
Action.Static.write_file target
@@ Pipeline.pipe_files ~seperator:"\n"
Path.[ rel [ "css"; "reset.css" ]; rel [ "css"; "style.css" ] ]

let page ~target file =
let target = Resolver.page ~target file in
Action.write_static_file target
Action.Static.write_file_with_metadata target
(let open Task in
track_binary
>>> Yocaml_yaml.Pipeline.read_file_with_metadata (module Repr.Page) file
>>> Yocaml_omd.content_to_html ()
>>> Yocaml_jingoo.Pipeline.as_template
(module Repr.Page)
(Path.rel [ "templates"; "main.html" ])
>>> drop_first ())
(Path.rel [ "templates"; "main.html" ]))

let article ~target file =
let target = Resolver.article ~target file in
Action.write_static_file target
Action.Static.write_file_with_metadata target
(let open Task in
track_binary
>>> Yocaml_yaml.Pipeline.read_file_with_metadata (module Repr.Article) file
Expand All @@ -40,8 +32,7 @@ let article ~target file =
(Path.rel [ "templates"; "article.html" ])
>>> Yocaml_jingoo.Pipeline.as_template
(module Repr.Article)
(Path.rel [ "templates"; "main.html" ])
>>> drop_first ())
(Path.rel [ "templates"; "main.html" ]))

let pages ~target =
Action.batch ~only:`Files ~where:(Path.has_extension "md")
Expand All @@ -53,15 +44,15 @@ let articles ~target =

let atom ~target =
let articles = Path.rel [ "articles" ] in
Action.write_static_file
Action.Static.write_file
Path.(target / "atom.xml")
(let open Task in
Pipeline.track_file articles
>>> Repr.Articles.to_atom (Path.rel [ "articles" ]))

let index ~target =
let articles = Path.rel [ "articles" ] in
Action.write_static_file
Action.Static.write_file_with_metadata
Path.(target / "index.html")
(let open Task in
track_binary
Expand All @@ -76,8 +67,7 @@ let index ~target =
(Path.rel [ "templates"; "articles.html" ])
>>> Yocaml_jingoo.Pipeline.as_template
(module Repr.Articles)
(Path.rel [ "templates"; "main.html" ])
>>> drop_first ())
(Path.rel [ "templates"; "main.html" ]))

let all ~target () =
let open Eff in
Expand Down

0 comments on commit 750ffc4

Please sign in to comment.