Skip to content

fix: reprocess future posts after publish date#5782

Open
puneetdixit200 wants to merge 2 commits into
hexojs:masterfrom
puneetdixit200:fix-future-post-cache-relations
Open

fix: reprocess future posts after publish date#5782
puneetdixit200 wants to merge 2 commits into
hexojs:masterfrom
puneetdixit200:fix-future-post-cache-relations

Conversation

@puneetdixit200

Copy link
Copy Markdown

What does it do?

Fixes #5642.

When future: false hides a future-dated post, Hexo strips its tag/category relations while processing. The source cache was still saved as clean, so once the post date passed, a later hexo generate could skip the unchanged source file and leave tag/category pages missing until the post changed or the site was cleaned.

This keeps published future-dated posts dirty in the source cache while future: false, so the next generate after their publish date reprocesses the post and restores its relations.

Screenshots

N/A

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

Local verification:

  • TS_NODE_CACHE=false npm_config_cache=/tmp/hexo-5671-npm-cache npx mocha test/scripts/console/generate.ts --require ts-node/register --grep "reprocesses future posts" --timeout 60000
  • TS_NODE_CACHE=false npm_config_cache=/tmp/hexo-5671-npm-cache npx mocha test/scripts/processors/post.ts --require ts-node/register --timeout 60000
  • npm_config_cache=/tmp/hexo-5671-npm-cache npm run build
  • npm_config_cache=/tmp/hexo-5671-npm-cache npx eslint lib/plugins/processor/post.ts test/scripts/console/generate.ts
  • npm_config_cache=/tmp/hexo-5671-npm-cache npm run eslint
  • git diff --check

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

How to test

git clone -b fix-future-post-cache-relations https://github.com/puneetdixit200/hexo.git
cd hexo
npm install
npm test

@stevenjoezhang stevenjoezhang force-pushed the fix-future-post-cache-relations branch from b00218d to 105c606 Compare July 4, 2026 04:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an edge case in Hexo’s source caching where future-dated posts processed with future: false could permanently lose tag/category relations until the post content changed or the site was cleaned. The PR ensures such posts remain “dirty” in the cache while they are still future-dated, so they will be reprocessed automatically after their publish date passes.

Changes:

  • Mark future-dated posts as dirty in the Cache model when future: false, forcing reprocessing on subsequent generates.
  • Add a regression test that simulates time passing and verifies tags/categories are restored after the publish date.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/plugins/processor/post.ts Forces cache invalidation for hidden future-dated posts so they will be reprocessed once they become publishable.
test/scripts/console/generate.ts Adds a time-travel regression test to ensure tags/categories are regenerated correctly after the publish date passes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yoshinorin yoshinorin mentioned this pull request Jul 9, 2026
function markFuturePostDirty(ctx: Hexo, file: _File, post: PostSchema) {
if (ctx.config.future || post.published === false || !post.date || post.date.valueOf() <= Date.now()) return;

const id = file.source.substring(ctx.base_dir.length).replace(/\\/g, '/');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part seem odd. Don't we have better properties representing what is needed here? Instead of respliting

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.

future: false not generating properly categories and tag pages

4 participants