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"})
16 (link-item {:url "https://git.omarpolo.com", :text "Git repos"})]]
18 [:h1 [:a {:href "/"} "yumh"]]
19 [:p "writing about things, sometimes."]]]))
22 [{:keys [title class description], :as d} & body]
25 [:meta {:charset "utf8"}]
26 [:meta {:name "viewport", :content "width=device-width, initial-scale=1"}]
27 [:link {:rel "shortcut icon", :href "/favicon.ico"}]
28 [:link {:rel "alternative" :type "application/rss+xml" :href "https://www.omarpolo.com/rss.xml"}]
30 [:meta {:name "description" :content description}])
32 (include-css "/css/style.css")]
33 [:body {:class (or class "")}
37 [:p "Blog proudly generated with "
38 [:a {:href "https://git.omarpolo.com/blog/"}
39 [:code "(clojure)"]]]]
41 [:img {:src "https://goatcounter.omarpolo.com/count?p=/test-img"}]]
42 [:script {:data-goatcounter "https://goatcounter.omarpolo.com/count"
44 :src "//goatcounter.omarpolo.com/count.js"}]]))
47 [{:keys [full? title-with-link?]}
48 {:keys [title date slug tags short body toot music], :as post}]
55 [:a {:href (str "/post/" slug ".html")} title]
57 [:p.author "Written by " [:em "Omar Polo"] " on " (time/fmt-loc date)
59 (list " while was listening to " [:a {:href (:url music)
62 "\"" [:em (:title music)] "\"" " by " [:em (:by music)]] ".")
64 [:ul.tags (map #(vector :li [:a {:href (str "/tag/" (name %) ".html")}
70 :rel "noopener"} "Comments over ActivityPub"]])]
73 (markdown->hiccup default-config body)
77 [{:keys [posts has-next has-prev nth]}]
78 (with-page {:title "Home"}
79 (map (partial post-fragment {:title-with-link? true})
83 [:a.prev {:href (str "/" (if (= (dec nth) 1)
88 [:a.next {:href (str "/" (inc nth) ".html")}
92 [{:keys [title short], :as post}]
93 (with-page {:title title
96 (post-fragment {:full? true}
101 (with-page {:title "All tags"
106 (map #(vector :li [:a {:href (str "/tag/" (name %) ".html")} (str "#" (name %))])
108 (compare (.toLowerCase (name a))
109 (.toLowerCase (name b)))) tags))]]))
113 (with-page {:title (str "Posts tagged with #" tag)
115 [:h2 "Posts tagged with " [:code "#" tag]]
116 (map (partial post-fragment {:title-with-link? true})