diff --git a/flake.nix b/flake.nix index 7a6b1ab..d3792a9 100644 --- a/flake.nix +++ b/flake.nix @@ -7,7 +7,7 @@ pkgs = nixpkgs.legacyPackages.${platform}; in { devShell.${platform} = pkgs.mkShell { - buildInputs = [ pkgs.janet ]; + buildInputs = with pkgs; [ janet multimarkdown ]; }; }; } diff --git a/index.janet b/index.janet index 3aa4858..f1c7c55 100644 --- a/index.janet +++ b/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)))]]))}}) diff --git a/posts/2021-07-07--let-there-be-light.md b/posts/2021-07-07--let-there-be-light.md new file mode 100644 index 0000000..8eab273 --- /dev/null +++ b/posts/2021-07-07--let-there-be-light.md @@ -0,0 +1,6 @@ +title: Let There Be Light +some: frontmatter +--- +# Hello World + +This is an example post. diff --git a/posts/transclude_text.txt b/posts/transclude_text.txt new file mode 100644 index 0000000..fcdb8dc --- /dev/null +++ b/posts/transclude_text.txt @@ -0,0 +1 @@ +Oh wowzers, this is coming from within another file!