diff --git a/deps.edn b/deps.edn index 3441ed9..0540c43 100644 --- a/deps.edn +++ b/deps.edn @@ -30,4 +30,5 @@ http-kit {:mvn/version "2.3.0"} compojure {:mvn/version "1.6.1"} watchtower {:mvn/version "0.1.1"} + clj-org/clj-org {:mvn/version "0.0.2"} com.taoensso/timbre {:mvn/version "4.10.0"}}} diff --git a/example/blog/about.org b/example/blog/about.org new file mode 100644 index 0000000..c0a027f --- /dev/null +++ b/example/blog/about.org @@ -0,0 +1,27 @@ +#+TITLE: Sur Moi +#+TAGS: foo bar baz + +* A blog page! + +Now /this/ is content! + + +** A subheading + +Woah + +* What about formatting? + +A list? + +- *BOLD* +- /Italic/ +- ~fixed-width~ + +#+BEGIN_SRC clojure +(defn hello + ([] "Greetings, nerd") + ([name] (format "Greetings %s" name))) + +(hello "friend") +#+END_SRC diff --git a/example/site.clj b/example/site.clj index 4515f63..2a0783e 100644 --- a/example/site.clj +++ b/example/site.clj @@ -13,7 +13,15 @@ (stylesheet global-style)] [:body content]]) +(def-asset about-page + {:path "/about.html" + :type :html + :data (let [{title :title + content :content} + (parse-org "./example/blog/about.org")] + (page title content))}) + (def-asset home-page {:path "/index.html" :type :html - :data (page "Hello world" [:p "This is magic"])}) + :data (page "Hello world" [:a {:href (asset-path about-page)} "This is a blog link."])}) diff --git a/src/teknql/statik/core.clj b/src/teknql/statik/core.clj index 886a735..2094fa1 100644 --- a/src/teknql/statik/core.clj +++ b/src/teknql/statik/core.clj @@ -7,6 +7,7 @@ [garden.color] [garden.stylesheet] [garden.units] + [clj-org.org] [clojure.string :as str]) (:refer-clojure :exclude [compile])) @@ -81,6 +82,12 @@ (str/replace "." "/")) ".clj")) +(defn parse-org [path] + "Take a path and return a map of title and content." + (-> path + (slurp) + (clj-org.org/parse-org))) + (defn eval-string "Ealuates the provided string. Returns a list of assets defined by the file." [s] @@ -101,6 +108,7 @@ 'user) {'def-asset def-asset 'asset-path asset-path 'stylesheet stylesheet + 'parse-org parse-org 'register-asset! #(swap! assets conj %)}} (map (juxt identity ns-interns) included-namespaces))}) @assets))