~subsetpark/bagatto

ref: 3ab1647981984556aaf4e2678d549eb83c302dcb bagatto/demo/vendoring/index.janet -rw-r--r-- 920 bytes
3ab16479 — Zach Smith Add vendoring demo 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# This site manages dependencies with `project.janet`. We can then use
# `jpm deps` to draw down dependencies as with a normal Janet project.
#
# Running `bag index.janet` will fail if `mago` is not
# available. However, we can make it available by either:
#
# 1. Using `jpm` to install it globally;
# 2. Using `JANET_PATH=... jpm` to install it locally, and then
#    setting the `JANET_PATH` env var when we invoke `bag` as well.
#
# In this example, I've set `JANET_PATH=janet_modules` and installed
# my dependencies to that folder.
(import mago)

(defn parse-mago
  [src attrs]
  (let [{:front front :body body} (mago/parse src)]
    (put attrs :body body)
    (merge-into attrs front)))

(def data {:pages {:src (bagatto/slurp-* "*.md") :attrs parse-mago}})
(def site {:pages {:each :pages
                   :dest (bagatto/%p '%i :title '% ".html")
                   :out (bagatto/renderer "templates/page") }})