aboutsummaryrefslogtreecommitdiff
path: root/lib/blog/sidebar.ml
blob: 1df0f1a6d8249653787565c44a722abe55122d48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
        )