mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-07 13:39:35 +08:00
feat(core): 增加 sorted 参数来控制结果排序 (#10744)
* feat: 增加 `sorted` 参数来控制结果排序 * feat: 添加 `sorted` 参数的测试 重用了 `sort` 的代码和数据:是不是可以考虑将两者结合?
This commit is contained in:
@@ -54,7 +54,9 @@ module.exports = async (ctx, next) => {
|
||||
ctx.state.data.description && (ctx.state.data.description = entities.decodeXML(ctx.state.data.description + ''));
|
||||
|
||||
// sort items
|
||||
ctx.state.data.item = ctx.state.data.item.sort((a, b) => +new Date(b.pubDate || 0) - +new Date(a.pubDate || 0));
|
||||
if (ctx.query.sorted !== 'false') {
|
||||
ctx.state.data.item = ctx.state.data.item.sort((a, b) => +new Date(b.pubDate || 0) - +new Date(a.pubDate || 0));
|
||||
}
|
||||
|
||||
const handleItem = (item) => {
|
||||
item.title && (item.title = entities.decodeXML(item.title + ''));
|
||||
|
||||
Reference in New Issue
Block a user