From c46119dc8ab4a049f131be07b6850194cc04f8f3 Mon Sep 17 00:00:00 2001 From: tourist <49434568+Blank0120@users.noreply.github.com> Date: Fri, 25 Oct 2024 01:22:29 +0800 Subject: [PATCH] fix(route/nodejs): Aready has official rss, and tweak selector of nodejs, but still has language error. (#17289) --- lib/routes/nodejs/blog.ts | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/routes/nodejs/blog.ts b/lib/routes/nodejs/blog.ts index 4153209e3..0d3700e7c 100644 --- a/lib/routes/nodejs/blog.ts +++ b/lib/routes/nodejs/blog.ts @@ -25,7 +25,8 @@ export const route: Route = { name: 'News', maintainers: ['nczitzk'], handler, - description: `| العربية | Catalan | Deutsch | Español | زبان فارسی | + description: `Official RSS Source: https://nodejs.org/en/feed/blog.xml + | العربية | Catalan | Deutsch | Español | زبان فارسی | | ------- | ------- | ------- | ------- | ---------- | | ar | ca | de | es | fa | @@ -55,16 +56,22 @@ async function handler(ctx) { const $ = load(response.data); - $('.summary').remove(); - - let items = $('ul.blog-index li a') + let items = $('article') .toArray() - .map((item) => { - item = $(item); + .map((article) => { + const $article = load(article); + + const author = $article('footer p').text(); + const pubDate = parseDate($article('footer time').attr('datetime')); + + const title = $article('a[aria-label]').prop('aria-label'); + const href = $article('a[aria-label]').attr('href'); return { - title: item.text(), - link: `${rootUrl}${item.attr('href')}`, + title, + link: `${rootUrl}${href}`, + author, + pubDate, }; }); @@ -76,17 +83,9 @@ async function handler(ctx) { url: item.link, }); - const content = load(detailResponse.data); - - item.pubDate = parseDate(content('time').attr('datetime')); - item.author = content('.blogpost-meta') - .text() - .match(/by (.*), /)?.[1]; - - content('.blogpost-header').remove(); - - item.description = content('article').html(); + const $content = load(detailResponse.data); + item.description = $content('main').html(); return item; }) )