fix(permalink): use permalink
for parse filename if parsing with new_post_name
fails
#5660
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does it do?
refs: #5658
In this PR, if parsing fails in
parseFilename
function withnew_post_name
, parsing will be attempted usingpermalink
instead.I've marked this PR as a draft for the following reasons:
Description
I noticed that
new_post_name
in_config.yml
is used for generating theslug
. As a result, thepost.permalink
variable seems to be getting an unexpected value.Example
For example:
new_post_name
to:year/:month/:day/:title.md
permalink
in_config.yml
to:title.html
With this configuration, the
post.permalink
forsource/_posts/foo bar/index.md
becomeshttp://example.com/yyyy/mm/dd/foo-bar-
. I think, this is likely not the intended value.Cause
The issue arises because the
parseFilename
function usesnew_post_name
to parse the filename, and when that fails, it returns the article title as the result. This result is then used as theslug
.From what I can see, this behavior has been there since the early implementation, though I don't think it was intentional.
Others
Also, there's no way for users to realize that the
new_post_name
setting affects theslug
. Based on its name, this setting should be used only for post creation, not for anything else. In the future, this value should not be used outside of post creation. However, making this change might inevitably affect existing users...Screenshots
N/A
Pull request tasks