Add markdown post rendering
This commit is contained in:
parent
6b8a916cd5
commit
905931b815
4 changed files with 23 additions and 6 deletions
|
|
@ -7,7 +7,7 @@
|
|||
pkgs = nixpkgs.legacyPackages.${platform};
|
||||
in {
|
||||
devShell.${platform} = pkgs.mkShell {
|
||||
buildInputs = [ pkgs.janet ];
|
||||
buildInputs = with pkgs; [ janet multimarkdown ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
20
index.janet
20
index.janet
|
|
@ -1,14 +1,24 @@
|
|||
(import janet-html :as html)
|
||||
(import path)
|
||||
|
||||
(defn as-html [h]
|
||||
(html/encode (html/doctype :html5) h))
|
||||
(html/encode (html/doctype :html5) [:html h]))
|
||||
|
||||
(bagatto/set-output-dir! "site")
|
||||
|
||||
(def img-path-copier (bagatto/path-copier "static"))
|
||||
(def data {:config {:attrs {:title "arnes.space"}}
|
||||
:posts {:src (bagatto/slurp-* "posts/*.md")
|
||||
:attrs bagatto/parse-mmarkdown}})
|
||||
|
||||
(def data {:dogs {:src (bagatto/* "images/*")
|
||||
:attrs bagatto/parse-base}})
|
||||
(defn header [data]
|
||||
[:head
|
||||
[:meta {:charset "utf-8"}]
|
||||
[:title (get-in data [:config :title])]])
|
||||
|
||||
(def site {:index {:dest "index.html"
|
||||
:out (fn [_] (as-html [:h1 "Hello World!"]))}})
|
||||
:out (fn [data]
|
||||
(as-html [(header data) [:body [:h1 "Hello World"]]]))}
|
||||
:posts {:each :posts
|
||||
:dest (bagatto/%p "posts" '%i "title" '% ".html")
|
||||
:out (fn [data item]
|
||||
(as-html [(header data) [:body (html/raw (bagatto/mmarkdown->html (item :contents)))]]))}})
|
||||
|
|
|
|||
6
posts/2021-07-07--let-there-be-light.md
Normal file
6
posts/2021-07-07--let-there-be-light.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
title: Let There Be Light
|
||||
some: frontmatter
|
||||
---
|
||||
# Hello World
|
||||
|
||||
This is an example post.
|
||||
1
posts/transclude_text.txt
Normal file
1
posts/transclude_text.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
Oh wowzers, this is coming from within another file!
|
||||
Loading…
Add table
Add a link
Reference in a new issue