summaryrefslogtreecommitdiff
path: root/build.clj
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-04-07 16:01:54 +0800
committereltrac <hi@eltr.ac>2026-04-07 16:01:54 +0800
commit0644feeed064479e90fa343ffc0da55720a6e76a (patch)
tree7dc2752bcece639d8f4523fc19c9e7cb2826c62b /build.clj
parenta8e5d0fcc495ee25797baef512cad3a64d1e2f29 (diff)
chore: use them/venin and make sure build script works
Diffstat (limited to 'build.clj')
-rw-r--r--build.clj73
1 files changed, 16 insertions, 57 deletions
diff --git a/build.clj b/build.clj
index 330caa28..c42ef31e 100644
--- a/build.clj
+++ b/build.clj
@@ -2,28 +2,11 @@
;; Usage: bb build.clj <no_chache?> <rebuild_scripts?>
(require '[babashka.tasks :refer [shell]])
-(require '[babashka.fs :as fs])
;; configuration
-
-(def go-scripts ["extract_highlights"
- "get_external_link_rank"
- "get_internal_link_graph"])
-(def site-path "public/")
-(def feed-path (str site-path "index.xml"))
-
-;; utilities
-
-(defn src-path [s]
- (str "scripts/" s ".go"))
-(defn bin-path [s]
- (str "bin/" s))
-
-(defn pnpm [& args]
- (apply shell "pnpm" args))
+(def theme-path "themes/venin")
;; banner
-
(defn banner []
(println "
▐
@@ -38,57 +21,33 @@
;; build steps
(defn pull-new-changes []
- (shell "git" "pull"))
+ ;; pull from content repository
+ (println "☠︎ Pulling from content repository...")
+ (shell "git" "pull")
+ ;; pull from theme repository
+ (println "☠︎ Pulling from theme repository...")
+ (shell {:dir theme-path} "git" "pull"))
-(defn build-unocss []
- (shell "pnpm" "build:uno:prod"))
-
-(defn build-go-scripts [on-demand]
- (when-not (fs/exists? "bin")
- (fs/create-dir "bin"))
- (cond->> go-scripts
- true (filter #(fs/exists? (src-path %)))
- on-demand (remove #(fs/exists? (bin-path %)))
- true (map (fn [s]
- (println "Building script" s)
- (shell "go" "build" "-o"
- (bin-path s)
- (src-path s))))
- true doall))
-
-(defn run-go-scripts []
- (->> go-scripts
- (map bin-path)
- (filter fs/exists?)
- (map (fn [s]
- (println "Running script" s)
- (shell s)))
- doall))
+(defn build-theme [step]
+ (println (str "☠︎ " step "-building theme..."))
+ (shell {:dir theme-path} "bb" "build.clj" (str step "-build")))
(defn build-site [no-cache?]
+ (println "☠︎ Generating static site...")
(shell "hugo" "--gc" "--minify"
(cond no-cache? "--ignoreCache")))
-(defn index-pagefind-search []
- (pnpm "pagefind" "--site" site-path))
-
-(defn send-webmentions []
- (pnpm "wm" feed-path "--limit" "1" "--send"))
-
;; main process
-(defn before-build-site [rebuild-scripts?]
+(defn before-build-site []
(pull-new-changes)
- (build-unocss)
- (build-go-scripts (not (parse-boolean (or rebuild-scripts? "false"))))
- (run-go-scripts))
+ (build-theme "pre"))
(defn after-build-site []
- (index-pagefind-search)
- (send-webmentions))
+ (build-theme "post"))
-(let [[no-cache? rebuild-scripts?] *command-line-args*]
+(let [[no-cache?] *command-line-args*]
(banner)
- (before-build-site rebuild-scripts?)
+ (before-build-site)
(build-site (parse-boolean (or no-cache? "false")))
(after-build-site))