Proxy Information
Original URL
gemini://hedy.smol.pub/2025-01-09
Status Code
Success (20)
Meta
text/gemini => //smol.hedy.dev smol.hedy.dev ``` . * \|/ . o -*- o + o . o + --*-- * . ' . * . o , . o . . /|\ + . + . -*- . . * - o ' . * - ·:· * . * . * o ``` # static-site generation with pandoc, fennel, and make I'm experimenting with a potential ssg set up using pandoc to process source files (eg, markdown), fennel for html templating using a rudimentary hiccup-like library, and makefiles to glue it all together. largely inspired by the fennel-lang.org website itself: => https://git.sr.ht/~technomancy/fennel-lang.org/ pandoc is a huge binary. I never really gave it much attention before because of this. but since looking into it more carefully this time around, it turns out it can be pretty customizable -- its own templating and even filters to manipulate the AST. pandoc 2.0 started bundling a lua interpreter and added support for native filters using lua. which means I can write filters in fennel and use a simple target in makefile, ie: ``` %.lua: %.fnl fennel --compile $< > $@ ``` templates are trivial in fennel. have each function return a list representing the html structure. reuse existing functions and pass parameters to achieve template/layout inheritance: ``` (fn base [ctx] [:html {:lang "en"} [:head {} [:meta {:charset "UTF-8"}] [:meta {:name "description" :content ctx.description}] [:link {:rel "stylesheet" :href "/main.css"}] [:title {} ctx.title]] [:body {} [:header {} "..."] ctx.main [:footer {} [:p {} "..."]]]]) (fn default [ctx] (local main [:main {} [:article {:itemprop "mainEntityOfPage"} [:header {:id "post-header"} [:hi {:itemprop "name headline" :class "p-name"} ctx.title]] [:section {:itemprop "articlebody" :class "e-content"} ctx.content]] [:br {}]]) (set ctx.main main) (base ctx)) {: base : default} ``` converting markdown into html can be done with intermediate files when calling pandoc. make can even automatically remove them: ``` HTML := public/*.html public/**/*.html DEFAULT_GOAL: $(HTML) %.lua: %.fnl fennel --compile $< > $@ content/%.html: filter.lua content/%.md pandoc -f gfm -t html --lua-filter=filter.lua $< -o $@ public/%.html: main.fnl content/%.html fennel main.fnl < $< > $@ ``` for example, if content/index.html didn't exist to begin with, you will see a "rm content/index.html" at the end of the output in make. custom syntax highlighting can also be done in pandoc. guess what? you can't do that with Hugo (a popular ssg) and Chroma (the syntax highlighting library it uses). shortcodes can be achieved with those lua filters in pandoc. one example is even included in the docs: => https://pandoc.org/lua-filters.html#replacing-placeholders-with-their-metadata-value I believe this is enough as a sort of ad-hoc static site generator. I'm not confident to say it will certainly be a smooth road ahead, but hey, at least compared to others I've tried it sure as hell had been a great experience so far. ``` ' ` ` ` ' ` ` ` ` ` ` ` ` ` ' ` ` ` ` ' ` ' ` ` ' ` ' ` ` ' ` `` ``` => mailto:hedy.dev@protonmail.com reply via email => //smol.hedy.dev home
Capsule Response Time
227.334908 milliseconds
Gemini-to-HTML Time
0.008979 milliseconds

This content has been proxied by September (ba2dc).