2 (:require [blog.time :as time]
3 [hiccup.page :refer [html5 include-css]]
4 [commonmark-hiccup.core :refer [markdown->hiccup default-config]]))
6 (defn link-item [{:keys [url text]}]
7 [:li [:a {:href url} text]])
9 (defn header [{:keys [tags]}]
14 (link-item {:url "/", :text "Home"})
15 (link-item {:url "/tags.html", :text "All Tags"})]]
17 [:h1 [:a {:href "/"} "yumh"]]
18 [:p "writing about things, sometimes."]]]))
21 [{:keys [title class], :as d} & body]
24 [:meta {:charset "utf8"}]
25 [:meta {:name "viewport", :content "width=device-width, initial-scale=1"}]
26 [:link {:rel "shortcut icon", :href "/favicon.ico"}]
28 (include-css "/css/style.css")]
29 [:body {:class (or class "")}
33 [:p "Blog powered by "
34 [:code "(clojure)"]]]]))
37 [{:keys [full? title-with-link?]}
38 {:keys [title date slug tags short body], :as post}]
41 [:h1 (if title-with-link?
42 [:a {:href (str "/post/" slug ".html")} title]
44 [:p.author "Written by " [:em "Omar Polo"] " on " (time/fmt-loc date)]
45 [:ul.tags (map #(vector :li [:a {:href (str "/tag/" (name %) ".html")}
50 (markdown->hiccup default-config body)
54 [{:keys [posts has-next has-prev nth]}]
55 (with-page {:title "Home"}
56 (map (partial post-fragment {:title-with-link? true})
60 [:a.prev {:href (str "/" (if (= (dec nth) 1)
65 [:a.next {:href (str "/" (inc nth) ".html")}
69 [{:keys [title], :as post}]
70 (with-page {:title title
72 (post-fragment {:full? true}
77 (with-page {:title "All tags"
82 (map #(vector :li [:a {:href (str "/tag/" (name %) ".html")} (str "#" (name %))])
84 (compare (.toLowerCase (name a))
85 (.toLowerCase (name b)))) tags))]]))
89 (with-page {:title (str "Posts tagged with #" tag)
91 [:h2 "Post tagged with " [:code "#" tag]]
92 (map (partial post-fragment {:title-with-link? true})