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"}]
27 [:link {:rel "alternative" :type "application/rss+xml" :href "https://www.omarpolo.com/rss.xml"}]
29 (include-css "/css/style.css")]
30 [:body {:class (or class "")}
34 [:p "Blog powered by "
35 [:code "(clojure)"]]]]))
38 [{:keys [full? title-with-link?]}
39 {:keys [title date slug tags short body], :as post}]
42 [:h1 (if title-with-link?
43 [:a {:href (str "/post/" slug ".html")} title]
45 [:p.author "Written by " [:em "Omar Polo"] " on " (time/fmt-loc date)]
46 [:ul.tags (map #(vector :li [:a {:href (str "/tag/" (name %) ".html")}
51 (markdown->hiccup default-config body)
55 [{:keys [posts has-next has-prev nth]}]
56 (with-page {:title "Home"}
57 (map (partial post-fragment {:title-with-link? true})
61 [:a.prev {:href (str "/" (if (= (dec nth) 1)
66 [:a.next {:href (str "/" (inc nth) ".html")}
70 [{:keys [title], :as post}]
71 (with-page {:title title
73 (post-fragment {:full? true}
78 (with-page {:title "All tags"
83 (map #(vector :li [:a {:href (str "/tag/" (name %) ".html")} (str "#" (name %))])
85 (compare (.toLowerCase (name a))
86 (.toLowerCase (name b)))) tags))]]))
90 (with-page {:title (str "Posts tagged with #" tag)
92 [:h2 "Post tagged with " [:code "#" tag]]
93 (map (partial post-fragment {:title-with-link? true})