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.
描述问题(Describe the Bug)
在博客文章详情页中,点击“上一篇”按钮时,跳转的不是当前文章的上一篇,而是整个博客的第一篇文章。
复现步骤(To Reproduce)
期望行为(Expected behavior):
应该跳转到当前文章的上一篇(发布时间或者 id 更小的一篇)。
实际行为(Actual behavior):
跳转到了整个博客的第一篇文章。
问题原因分析(Possible Cause)
在
getPreArticle方法中,查询逻辑是:由于
ORDER BY article_id是升序排列,导致拿到了所有比当前 id 小的文章中最小 id 的那篇,而不是最近的一篇。建议修复(Suggested Fix)
将
ORDER BY语句修改为降序排列:这样就能正确取到最近的上一篇文章。
补充信息(Additional context)
测试环境:
感谢作者的辛苦开发!❤️
希望项目越来越好!