fix(route/anthropic): ensure news route includes article content (#20205)

* fix(route/anthropic): ensure news route includes article content

* refactor: change order of maintainers array

* refactor: simplify selector for redundant elements that should be removed

* refactor: remove redundant codeblock control elements
This commit is contained in:
Goestav
2025-09-30 22:57:03 +08:00
committed by GitHub
parent 28f3b5a0a5
commit e196e2aac7
+12 -3
View File
@@ -15,7 +15,7 @@ export const route: Route = {
},
],
name: 'News',
maintainers: ['etShaw-zh'],
maintainers: ['etShaw-zh', 'goestav'],
handler,
url: 'www.anthropic.com/news',
};
@@ -49,9 +49,18 @@ async function handler(ctx) {
const response = await ofetch(item.link!);
const $ = load(response);
$('div[class^="PostDetail_b-social-share"]').remove();
const content = $('#main-content');
// Remove meaningless information (heading, sidebar, quote carousel, footer and codeblock controls)
$(`
[class^="PostDetail_post-heading"],
[class^="ArticleDetail_sidebar-container"],
[class^="QuoteCarousel_carousel-controls"],
[class^="PostDetail_b-social-share"],
[class^="LandingPageSection_root"],
[class^="CodeBlock_controls"]
`).remove();
const content = $('div[class*="PostDetail_post-detail__"]');
content.find('img').each((_, e) => {
const $e = $(e);
$e.removeAttr('style srcset');