You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
756 B
38 lines
756 B
(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)
|
|
"..."
|
|
""))))
|
|
|