Skip to content

Commit

Permalink
fix(route/sciencenet): 修复科学网 - 用户博客没有按照时间线倒序排序 (#17007)
Browse files Browse the repository at this point in the history
  • Loading branch information
ueiu authored Oct 7, 2024
1 parent 8a60688 commit 3f7c467
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/routes/sciencenet/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const route: Route = {

async function handler(ctx) {
const id = ctx.req.param('id');
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50;

const rootUrl = 'https://blog.sciencenet.cn';
const currentUrl = `${rootUrl}/u/${id}`;
Expand All @@ -51,8 +52,9 @@ async function handler(ctx) {
$ = load(response.data);

let items = $('item')
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50)
.slice(-limit)
.toArray()
.reverse()
.map((item) => {
item = $(item);

Expand Down

0 comments on commit 3f7c467

Please sign in to comment.