Skip to content

Commit

Permalink
fix: only try to code highlight .html pages
Browse files Browse the repository at this point in the history
  • Loading branch information
bjagg committed Aug 25, 2023
1 parent ee68edc commit 9a63409
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/clj/upwebsite/web.clj
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@
:partials (partial-pages (stasis/slurp-directory "resources/partials" #".*\.html$"))
:markdown (markdown-pages (stasis/slurp-directory "resources/md" #".*\.md$"))}))

(defn prepare-page [page req]
(-> (if (string? page) page (page req))
highlight-code-blocks))

(defn prepare-pages [pages]
(defn prepare-page
"From a URL:page pair and request, create the page (if not a string) and post-process."
[[url page] req]
(let [prep-page (if (string? page) page (page req))] ;; page is string or fn
(if (str/ends-with? url ".html")
(highlight-code-blocks prep-page)
prep-page)))

(defn prepare-pages
"Create a map of URLs -> (pepare-page page) functions from map of URL -> raw pages."
[pages]
(zipmap (keys pages)
(map #(partial prepare-page %) (vals pages))))
(map #(partial prepare-page %) pages)))

(defn get-pages []
(prepare-pages (get-raw-pages)))
Expand Down

0 comments on commit 9a63409

Please sign in to comment.