The merged markdown-rendering change served /static from a disk directory,
but the live deployment only replaced the binary and templates, so
/static/js/markdown.js and /static/css/markdown.css 404'd and every
article/comment rendered empty (BlogMD was undefined and threw).
- main.go: serve /static from an embedded FS (go:embed) — deployments
now only need to replace the executable; no static dir to copy.
- install_linux.sh: drop the static directory copy (no longer needed).
- article.html / comment_list.html: if BlogMD is unavailable, fall back
to plain (HTML-escaped) text for the article body, comment bodies and
the comment preview, so content is never blank.
- README: document the static/ directory.
Verified locally: /static/* serve 200 even with the disk directory
removed; normal render path (25 checks) and the fallback path both pass.
kevin
merged commit 9c0ba8cd6d into main2026-08-18 18:18:47 +08:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
问题
PR #1 合并部署后,文章/评论内容全部不显示(https://haibara.ai/article/panel-auth-lock-your-ai-panel)。原因:Markdown 渲染的
static/资源是从磁盘目录提供的,但线上部署只更新了二进制和 templates,/static/js/markdown.js与/static/css/markdown.css404 →BlogMD未定义 → 渲染脚本抛错 → 正文与评论全部空白。修复
go:embed将 static 资源编入二进制(main.go):/static改由嵌入的 FS 提供,部署时只需要替换可执行文件,不再依赖服务器上有static/目录,杜绝此类部署错位。install_linux.sh移除不再需要的 static 目录拷贝;README 补充 static/ 说明。验证
go build/go vet)static/目录移走后重启服务,/static/js/markdown.js、/static/css/markdown.css仍返回 200(证明资源来自二进制)服务器重新部署方式(任选其一)