Skip to content

Commit

Permalink
Specify index file to rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Oct 29, 2024
1 parent 9f8589e commit 164b176
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
:to "static-site")}
rewrite-index
{:task (t/rewrite-index
:from "resources/public/index.html"
:to "static-site/index.html"
:from "resources/public"
:to "static-site"
:index-file "index.html"
:base-href "https://dgtized.github.io/shimmers/")}
;; For routing to page handler after not using fragments
;; ln -sf index.html 404.html
Expand Down
10 changes: 6 additions & 4 deletions src/bb/tasks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@
(bt/shell "bash" "-c" (str "ls -hs --format=single-column " js-dir release-glob))))

(defn rewrite-index [& opts]
(let [{:keys [from to base-href] :as opts} (default-opts opts)
(let [{:keys [index-file from to base-href] :as opts} (default-opts opts)
from-index (str (fs/path from index-file))
to-index (str (fs/path to index-file))
revision (git-revision)
timestamp (timestamp-iso8601)
contents (slurp from)]
(println "Rewriting" from "->" to)
contents (slurp from-index)]
(println "Rewriting" from-index "->" to-index)
(println " build:" timestamp "rev:" revision)
(spit to
(spit to-index
(-> contents
(str/replace-first #"<base href=\"\">"
(str "<base href=\"" base-href "\">"))
Expand Down

0 comments on commit 164b176

Please sign in to comment.