From 3f7c467b70e6e9351a33612d7196da38812dbee2 Mon Sep 17 00:00:00 2001 From: ueiu <39592269+ueiu@users.noreply.github.com> Date: Mon, 7 Oct 2024 08:26:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(route/sciencenet):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=A7=91=E5=AD=A6=E7=BD=91=20-=20=E7=94=A8=E6=88=B7=E5=8D=9A?= =?UTF-8?q?=E5=AE=A2=E6=B2=A1=E6=9C=89=E6=8C=89=E7=85=A7=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=BA=BF=E5=80=92=E5=BA=8F=E6=8E=92=E5=BA=8F=20(#17007)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/sciencenet/user.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/routes/sciencenet/user.ts b/lib/routes/sciencenet/user.ts index fbf3754566232d..9d4f79239e9195 100644 --- a/lib/routes/sciencenet/user.ts +++ b/lib/routes/sciencenet/user.ts @@ -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}`; @@ -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);