Explorar el Código

feat(hugo): 统一所有标题为衬线体,添加文件监控自动重新编译

Daily Deploy Bot hace 4 días
padre
commit
72e413a74b
Se han modificado 3 ficheros con 74 adiciones y 0 borrados
  1. 13 0
      deploy/rebuild-hugo.sh
  2. 37 0
      deploy/watch-hugo.sh
  3. 24 0
      site/static/css/site.css

+ 13 - 0
deploy/rebuild-hugo.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+# Hugo 自动重新编译脚本
+# 监控 obsidian 内容目录变化,自动重新编译
+
+cd /home/zhn/.openclaw/workspace/skills/robdaily/deploy
+
+# 等待文件稳定(避免频繁触发)
+sleep 2
+
+# 重新构建 Hugo
+docker compose exec -T hugo-personal-site hugo --minify
+
+echo "[$(date '+%Y-%m-%d %H:%M:%S')] Hugo 重新编译完成" >> /tmp/hugo-rebuild.log

+ 37 - 0
deploy/watch-hugo.sh

@@ -0,0 +1,37 @@
+#!/bin/bash
+# Hugo 文件监控守护进程
+# 监控 Obsidian 内容目录,自动重新编译
+
+HUGO_DIR="/home/zhn/.openclaw/workspace/skills/robdaily/deploy"
+CONTENT_DIR="/home/zhn/.openclaw/workspace/skills/robdaily/site/content"
+LOG_FILE="/tmp/hugo-watch.log"
+LOCK_FILE="/tmp/hugo-rebuild.lock"
+
+log() {
+  echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "$LOG_FILE"
+}
+
+rebuild() {
+  # 防抖:如果 30 秒内已执行过,跳过
+  if [ -f "$LOCK_FILE" ]; then
+    last_run=$(stat -c %Y "$LOCK_FILE" 2>/dev/null || echo 0)
+    current_time=$(date +%s)
+    if [ $((current_time - last_run)) -lt 30 ]; then
+      return
+    fi
+  fi
+  
+  log "开始重新编译 Hugo..."
+  cd "$HUGO_DIR"
+  docker compose exec -T hugo-personal-site hugo --minify 2>&1 | tail -5 >> "$LOG_FILE"
+  touch "$LOCK_FILE"
+  log "Hugo 重新编译完成"
+}
+
+# 监听内容目录
+log "开始监控:$CONTENT_DIR"
+inotifywait -m -r -e modify -e create -e delete --exclude '\.swp$' "$CONTENT_DIR" |
+while read -r directory event filename; do
+  log "文件变化:$event $filename"
+  rebuild
+done

+ 24 - 0
site/static/css/site.css

@@ -173,6 +173,7 @@ img {
 .site-nav a {
   color: var(--text);
   font-weight: 500;
+  font-family: "Cormorant Garamond", "Noto Serif SC", "Source Han Serif CN", serif;
   padding: 4px 2px;
   position: relative;
 }
@@ -255,6 +256,7 @@ img {
   padding: 12px 0;
   color: var(--text);
   font-weight: 500;
+  font-family: "Cormorant Garamond", "Noto Serif SC", "Source Han Serif CN", serif;
   font-size: 1rem;
   border-bottom: 1px solid rgba(47, 49, 45, 0.06);
 }
@@ -542,6 +544,28 @@ main.wrap {
   font-size: 1.3rem;
 }
 
+/* 正文内容中的标题使用衬线体 */
+.prose h1,
+.prose h2,
+.prose h3,
+.prose h4,
+.prose h5,
+.prose h6 {
+  font-family: "Cormorant Garamond", "Noto Serif SC", "Source Han Serif CN", serif;
+  font-weight: 600;
+  color: var(--text);
+  letter-spacing: -0.01em;
+  margin-top: 1.8em;
+  margin-bottom: 0.8em;
+}
+
+.prose h1 { font-size: 1.8rem; letter-spacing: -0.02em; }
+.prose h2 { font-size: 1.5rem; border-bottom: 1px solid rgba(92, 117, 96, 0.14); padding-bottom: 0.28em; }
+.prose h3 { font-size: 1.3rem; }
+.prose h4 { font-size: 1.15rem; }
+.prose h5 { font-size: 1.05rem; }
+.prose h6 { font-size: 1rem; }
+
 .prose :first-child {
   margin-top: 0;
 }