Skip to content

Fix publish filename resolution - #5805

Open
stevenjoezhang wants to merge 1 commit into
masterfrom
fix/publish-unpublish-filename-resolution
Open

Fix publish filename resolution#5805
stevenjoezhang wants to merge 1 commit into
masterfrom
fix/publish-unpublish-filename-resolution

Conversation

@stevenjoezhang

@stevenjoezhang stevenjoezhang commented Aug 6, 2026

Copy link
Copy Markdown
Member

What does it do?

This PR fixes draft filename resolution used by hexo publish:

  • Accepts exact filenames, including extensions such as .md and .mkd.
  • Accepts paths relative to _drafts, including nested directories.
  • Allows the extension to be omitted when the filename is unambiguous.
  • Prevents a filename such as foo from incorrectly matching foo-bar.md or foobar.md.
  • Reports an explicit error with the available candidates when multiple files have the same stem.
  • Handles filenames containing spaces.
  • Normalizes path separators and respects the filename_case configuration.
  • Separates source-file lookup from the slug used to create the destination post.

The destination filename continues to follow the existing new_post_name behavior.

This PR intentionally does not include the unpublish command or implementation. That work remains in #4995 so the original contribution and commit history are preserved.

Fixes #1821.
Supersedes #5476.

Screenshots

N/A — this change only affects CLI behavior.

Pull request tasks

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

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

How to test

git clone -b fix/publish-unpublish-filename-resolution https://github.com/hexojs/hexo.git
cd hexo
npm install
npm test

@yoshinorin yoshinorin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the original contribution should be preserved here. The description references #4995 by @awongCM in prose, but all commits are authored by you, so their contribution doesn't appear in the git history. When a change builds on an existing implementation, that attribution should be carried in the commits themselves, not only referenced in the PR description.

Given that, I think one of the following should happen:

  1. Have @awongCM recreate the work.
  2. Preserve @awongCM's commits during the rebase (though I suspect this was difficult given how old the original PR is).
  3. Get @awongCM's approval to merge this PR as is.

@stevenjoezhang
stevenjoezhang force-pushed the fix/publish-unpublish-filename-resolution branch from dc2a403 to 69968ef Compare August 26, 2026 14:33
@stevenjoezhang stevenjoezhang changed the title Add unpublish command and fix post filename resolution Fix publish filename resolution Aug 26, 2026
@stevenjoezhang

Copy link
Copy Markdown
Member Author

Thanks for pointing this out. I agree that the original contribution and its Git history should be preserved.

I have split the changes and force-pushed the PR on top of the latest master. #5805 now contains only the publish filename-resolution fix for #1821/#5476. The unpublish command, implementation, and tests have all been removed and remain in #4995.

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.

hexo publish draft.md don't look at the right filename + markdown extensions

2 participants