From 9a63409109ed8eb40bc7b213779b787833ce433e Mon Sep 17 00:00:00 2001 From: "Benito J. Gonzalez" Date: Fri, 25 Aug 2023 13:51:22 -0700 Subject: [PATCH] fix: only try to code highlight .html pages --- src/clj/upwebsite/web.clj | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/clj/upwebsite/web.clj b/src/clj/upwebsite/web.clj index 5652495..03602d9 100644 --- a/src/clj/upwebsite/web.clj +++ b/src/clj/upwebsite/web.clj @@ -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)))