From 77544bdfad2af41514ec1435f706fee87ea2969e Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 7 Feb 2022 15:38:37 +0100 Subject: Added viz.js code --- lib/blog/dune | 21 +++++++++++++++++++++ lib/blog/hash_host/hash_blog.ml | 1 + lib/blog/hash_host/hash_localhost.ml | 1 + lib/blog/nord.ml | 2 ++ lib/blog/sidebar.ml | 23 +++++++++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100755 lib/blog/dune create mode 100755 lib/blog/hash_host/hash_blog.ml create mode 100755 lib/blog/hash_host/hash_localhost.ml create mode 100755 lib/blog/nord.ml create mode 100755 lib/blog/sidebar.ml (limited to 'lib/blog') diff --git a/lib/blog/dune b/lib/blog/dune new file mode 100755 index 0000000..648990f --- /dev/null +++ b/lib/blog/dune @@ -0,0 +1,21 @@ +(rule + (targets hash_host.ml) + (enabled_if (= %{profile} dev)) + (action (copy# hash_host/hash_localhost.ml hash_host.ml))) + +(rule + (targets hash_host.ml) + (enabled_if (<> %{profile} dev)) + (action (copy# hash_host/hash_blog.ml hash_host.ml))) + +(library + (name blog) + (libraries + brr + brr.note + elements + ) + (preprocess (pps ppx_hash)) + + + ) diff --git a/lib/blog/hash_host/hash_blog.ml b/lib/blog/hash_host/hash_blog.ml new file mode 100755 index 0000000..f5e172e --- /dev/null +++ b/lib/blog/hash_host/hash_blog.ml @@ -0,0 +1 @@ +let expected_host = [%static_hash "blog.chimrod.com"] diff --git a/lib/blog/hash_host/hash_localhost.ml b/lib/blog/hash_host/hash_localhost.ml new file mode 100755 index 0000000..a41022e --- /dev/null +++ b/lib/blog/hash_host/hash_localhost.ml @@ -0,0 +1 @@ +let expected_host = [%static_hash "localhost"] diff --git a/lib/blog/nord.ml b/lib/blog/nord.ml new file mode 100755 index 0000000..f0f2772 --- /dev/null +++ b/lib/blog/nord.ml @@ -0,0 +1,2 @@ +let nord0 = Jstr.v "#2e3440" +let nord8 = Jstr.v "#81a1c1" diff --git a/lib/blog/sidebar.ml b/lib/blog/sidebar.ml new file mode 100755 index 0000000..1df0f1a --- /dev/null +++ b/lib/blog/sidebar.ml @@ -0,0 +1,23 @@ +open StdLabels +open Brr + +(** Return the sidebar *) +let get + : unit -> El.t option + = fun () -> + + List.find_opt (El.children @@ Document.body G.document) + ~f:(fun t -> El.has_tag_name El.Name.aside t) + +let rec clean + : El.t -> unit + = fun el -> + List.iter (El.children el) + ~f:(fun el -> + (* Remove the links from the sidebar, keep h1 and other stuff *) + if (El.has_tag_name (Jstr.v "nav") el) + || (El.has_tag_name (Jstr.v "ul") el) then + El.remove el + else + clean el + ) -- cgit v1.2.3