Skip to content

fix: 防止清空内容目录后构建仍保留旧动态和项目 - #679

Open
josemims31 wants to merge 1 commit into
CuteLeaf:masterfrom
josemims31:master
Open

josemims31 wants to merge 1 commit into
CuteLeaf:masterfrom
josemims31:master

Conversation

@josemims31

Copy link
Copy Markdown

问题与原因

删除全部动态或项目源文件后,再执行 pnpm build,生成的网站仍可能显示旧动态或旧项目。

本项目锁定 Astro 7.3.2。该版本的 glob loader 在内容目录存在、但没有匹配文件时会提前 return,跳过后续对旧内容记录的清理。因此,在已有内容缓存的情况下,清空目录后执行普通构建,仍可能从缓存生成已经删除的内容。

相关源码:

修改

在 package.json 的 build 脚本中,将 astro build 改为 astro build --force。

使用 Astro 提供的 --force 参数清除内容缓存,重新根据当前源文件生成内容,保留原有完整构建流程。

这是构建阶段的兼容处理,不涉及依赖升级或 Astro 内部代码修改。代价是每次构建都会重新同步内容,减少内容缓存带来的加速收益。

验证

  • [ x] pnpm check
  • [x ] pnpm type-check
  • [x ] pnpm build
  • [ x] 在测试副本中,先构建包含动态和项目的内容,再清空对应目录重新构建
  • 确认 dist/api/dynamic.json 为 []
  • [x ] 确认项目列表为空,旧项目详情页不再生成

fix: refresh content cache during production builds
@netlify

netlify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for demo-firefly ready!

Name Link
🔨 Latest commit dcb7762
🔍 Latest deploy log https://app.netlify.com/projects/demo-firefly/deploys/6ada3de97e3fca6125b9c321
😎 Deploy Preview https://deploy-preview-679--demo-firefly.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@josemims31 is attempting to deploy a commit to the xiaye's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant