From ae1f40e0ac1e86d4dbe01e09df098f7ea39a7bc5 Mon Sep 17 00:00:00 2001 From: Keo Date: Tue, 16 Sep 2025 23:40:02 +0800 Subject: [PATCH] fix(itch): incorrect devlog authors (#20073) * fix(itch): devlog authors * selector --- lib/routes/itch/devlog.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/routes/itch/devlog.ts b/lib/routes/itch/devlog.ts index f947d609d..bf3b167a8 100644 --- a/lib/routes/itch/devlog.ts +++ b/lib/routes/itch/devlog.ts @@ -36,6 +36,7 @@ export const route: Route = { async function handler(ctx) { const user = ctx.req.param('user') ?? ''; const id = ctx.req.param('id') ?? ''; + const limit = Number.parseInt(ctx.req.query('limit')) || 20; if (!isValidHost(user)) { throw new InvalidParameterError('Invalid user'); } @@ -51,6 +52,7 @@ async function handler(ctx) { let items = $('.title') .toArray() + .slice(0, limit) .map((item) => { item = $(item); @@ -71,12 +73,14 @@ async function handler(ctx) { const content = load(detailResponse.data); - item.author = detailResponse.data.match(/"author":{".*?","name":"(.*?)"/)[1]; - item.pubDate = parseDate(detailResponse.data.match(/"datePublished":"(.*?)"/)[1]); + const infoJson = content('script[type="application/ld+json"]:contains("@type":"BlogPosting")'); + const info = JSON.parse(content(infoJson).text()); + item.author = info.author.name; + item.pubDate = info.datePublished; item.description = art(path.join(__dirname, 'templates/description.art'), { images: content('.post_image') .toArray() - .map((i) => content(i).attr('src')), + .map((e) => content(e).attr('src')), description: content('.post_body').html(), });