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
Sesame.Collection
: tools for building collections with a type-checked metadata sectionSesame.Image
: tools for doing transformations like rescaling, dithering, quality changes etc. to imagesSesame.Responsive
: tools for building responsive imagesSesame.Path
: utility functions for mangling file pathsSesame.Transformer
: markdown to markdown transformations to do things like add table of contents, change images for responsive onesSesame.Utils
: provides useful functions and importantly some predefinedSesame
.S.S modules for common format likeSesame.Utils.Json
andSesame.Utils
.Yml.Sesame.Components
: some basic HTML componenets you may want to use