Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 回报:主题配置 → 文章页面:【sticky】对应的数字权重与使用指南不一致 #53

Closed
SuiteLHY opened this issue Apr 10, 2021 · 6 comments
Assignees
Labels
🐛bug Something isn't working

Comments

@SuiteLHY
Copy link
Contributor

SuiteLHY commented Apr 10, 2021

  1. 对Bug的描述:
    使用手册中的[主题配置 → 文章页面:【sticky】对应的数字权重]与所描述的“数字越大优先级越高”不一致,实际效果为[数字越大优先级越低]。

image

  1. 复现Bug的方法:
    image
    image
    image

  2. 期望的行为:
    方案一. 修正使用手册的对应配置项说明。
    方案二. 修改代码使配置项【sticky】实现的功能与使用手册的描述一致。

  3. 相关的截图:
    image

  4. 对应版本
    image

  5. 补充说明
    影响不大,小问题。有空就改,没空就摸鱼

@SuiteLHY SuiteLHY added the 🐛bug Something isn't working label Apr 10, 2021
@Candinya
Copy link
Owner

这个是 JavaScript 为弱类型的问题,"2147483647-1"会被当成一个字符串而非数学表达式来参与运算,进而计算出的结果为 NaN ,因而导致排序出错。如果换成"2147483646",那么序列的顺序就是正确的。
可以参考默认主页生成器的代码。

https://github.com/hexojs/hexo-generator-index/blob/1a637a04ea809d127a771810c30fbb18e08ca388/lib/generator.js#L9

image

@SuiteLHY
Copy link
Contributor Author

SuiteLHY commented Apr 10, 2021

这个是 JavaScript 为弱类型的问题,"2147483647-1"会被当成一个字符串而非数学表达式来参与运算,进而计算出的结果为 NaN ,因而导致排序出错。如果换成"2147483646",那么序列的顺序就是正确的。
可以参考默认主页生成器的代码。

https://github.com/hexojs/hexo-generator-index/blob/1a637a04ea809d127a771810c30fbb18e08ca388/lib/generator.js#L9

image

经过完整的测试,发现我最初的描述不准确,我的问题描述应该修正为👉使用手册中的[主题配置 → 文章页面:【sticky】对应的数字权重]与所描述的“数字越大优先级越高”不一致,实际效果为[创建时间越晚优先级越高]。

补充说明

  • 问题复现截图

image

编辑了创建时间为【2021-04-10 16:05:24】的数据后(排除了编辑时间的因素;确定了[在置顶文章之中]排序权重只与创建时间有关)

image

@Candinya
Copy link
Owner

image
这里无法复现。请注意这并不是一个主题特性,而是根据官方的首页文章排布方案做出的兼容与配合举措。请检查您的 hexo-generator-index 版本(在站点的package.json文件中),只有2.0.0开始的版本(目前只有2.0.0)才加入了 sticky 参数。
具体可以参见 hexo-generator-index 的 版本发布页面

@SuiteLHY
Copy link
Contributor Author

SuiteLHY commented Apr 10, 2021

image
这里无法复现。请注意这并不是一个主题特性,而是根据官方的首页文章排布方案做出的兼容与配合举措。请检查您的 hexo-generator-index 版本(在站点的package.json文件中),只有2.0.0开始的版本(目前只有2.0.0)才加入了 sticky 参数。
具体可以参见 hexo-generator-index 的 版本发布页面

我发现了,一开始我没有描述清楚,是在【分类】和【标签】列表下才出现的问题,主页列表没有问题(有问题的是某一条异常数据,和此 issue 无关)。

很抱歉,麻烦你有空再看看orz

补充

generator.js 的源码大致看了一下,没有问题-_-||

@Candinya
Copy link
Owner

Candinya commented Apr 16, 2021

是 hexo-generator-tag 和 hexo-generator-category 的问题,我提了两个PR用于跟进。
hexojs/hexo-generator-tag#46
hexojs/hexo-generator-category#44

@SuiteLHY
Copy link
Contributor Author

SuiteLHY commented May 2, 2021

非常感谢!👍❤

@SuiteLHY SuiteLHY closed this as completed May 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants