Files
simple-cljs-blog/src/main/blog/helpers.cljs
T

38 lines
756 B
Clojure

(ns blog.helpers
(:require ["date-fns" :refer [format]]))
(defn truncatestring-factory
[]
(fn [text limit]
(-> (. text substring 0 limit)
(str "..."))))
(defn full-timestamp-factory
[]
(clj->js
(fn [timestamp]
(format timestamp "HH:mm MMM. do, yyyy"))))
(defn article-timestamp-factory
[]
(clj->js
(fn [timestamp]
(str "<time pubdate=\""
(format timestamp "yyyy-MM-dd")
"\" datetime=\""
(format timestamp "yyyy-MM-dd")
"\" title=\""
(format timestamp "MMMM do, yyyy")
"\">"
(format timestamp "MMMM do, yyyy")
"</time>"))))
(defn is-brief-factory
[]
(clj->js
(fn [length]
(if (> length 60)
"..."
""))))