Sesame

A library of tools for building smaller, greener, less resource intensive and more accessible website and blogs inspired by https://solar.lowtechmagazine.com/.

The scope of Sesame has somewhat changed quite bit, but at its core is a set of hopefully useful tools for building websites, that's it.

A Simple Site

Sesame aims to provide a very easy way to have a site built. It may not look the best, but under-the-hood it tries to do the heavy lifting so you just need to override the build functionality to do custom HTML.

module Meta = struct
  type t = { title : string } [@@deriving yaml]
end

module C = Sesame.Collection.Make (Meta)
module H = Sesame.Collection.Html (Meta)

let build () =
  let open Lwt_result.Syntax in
  let* c = C.build (Fpath.v "data/index.md") in
  let+ html = H.build c in
  Fmt.(pf stdout "%s" html)

let () =
  match Lwt_main.run (build ()) with Ok _ -> () | Error (`Msg m) -> failwith m

This is the example/simple-sesame site, it actually just prints the generated HTML to stdout. To do more with it you could override H's build function. Something like:

module H = struct
  include Sesame.Collection.Html (Meta)

  let build (t : C.t) =
    let body =
      let open Tyxml.Html in
      [
        h1 [ txt t.meta.title ];
        div [ Unsafe.data (t.body |> Omd.of_string |> Omd.to_html) ];
      ]
    in
    Sesame.Components.html ~lang:"en" ~css:"/styles" ~title:t.meta.title
      ~description:"home page" ~body
    |> Fmt.str "%a" (Tyxml.Html.pp ())
    |> Lwt_result.return
end

The cool thing with overriding it is that you have access to the collection's metadata too!

Modules

  1. Sesame.Collection: tools for building collections with a type-checked metadata section
  2. Sesame.Image: tools for doing transformations like rescaling, dithering, quality changes etc. to images
  3. Sesame.Responsive: tools for building responsive images
  4. Sesame.Path: utility functions for mangling file paths
  5. Sesame.Transformer: markdown to markdown transformations to do things like add table of contents, change images for responsive ones
  6. Sesame.Utils: provides useful functions and importantly some predefined Sesame.S.S modules for common format like Sesame.Utils.Json and Sesame.Utils.Yml.
  7. Sesame.Components: some basic HTML componenets you may want to use