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
parseFilenamefunction withnew_post_name, parsing will be attempted usingpermalinkinstead.I've marked this PR as a draft for the following reasons:
Description
I noticed that
new_post_namein_config.ymlis used for generating theslug. As a result, thepost.permalinkvariable seems to be getting an unexpected value.Example
For example:
new_post_nameto:year/:month/:day/:title.mdpermalinkin_config.ymlto:title.htmlWith this configuration, the
post.permalinkforsource/_posts/foo bar/index.mdbecomeshttp://example.com/yyyy/mm/dd/foo-bar-. I think, this is likely not the intended value.Cause
The issue arises because the
parseFilenamefunction usesnew_post_nameto 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_namesetting 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