if "%choice%"=="1" goto new_post if "%choice%"=="2" goto preview if "%choice%"=="3" goto deploy if "%choice%"=="4" goto open_dir if "%choice%"=="5" goto clean if "%choice%"=="6" goto stats if "%choice%"=="0" exit goto menu
:new_post echo. set /p filename="请输入文件名 (建议英文/数字): " hugo new "posts/%filename%.md" echo ✅ 文章已创建: content/posts/%filename%.md :: 尝试用系统默认编辑器打开新文章 start "" "content/posts/%filename%.md" pause goto menu
:preview echo. echo 🚀 正在启动预览 (含草稿)... echo 💡 访问地址: http://localhost:1313 echo 💡 提示: 若标题不更新,请退出预览并执行[5]清理缓存 :: 使用 --disableFastRender 确保修改即生效,减少缓存问题 hugo server -D --disableFastRender pause goto menu
:deploy echo. echo 🧹 正在预处理: 清理旧文件并重新构建... ifexist public ( rd /s /q public ) hugo --gc --minify echo. echo 📤 正在同步至 GitHub... git add . set /p msg="请输入本次更新说明 (回车则默认 update): " if "%msg%"=="" set msg="update" git commit -m "%msg%" git push origin main echo. echo ✅ 全部完成!请等待 Vercel 自动化部署。 pause goto menu
:open_dir echo. echo 📂 正在打开内容目录... start explorer "content\posts" goto menu
:clean echo. echo 🧹 正在清理 Hugo 缓存与 Public 文件夹... hugo mod clean ifexist public ( rd /s /q public ) ifexist resources ( rd /s /q resources ) echo ✅ 清理完成! pause goto menu