rsshub
Version:
Make RSS Great Again!
43 lines (42 loc) • 1.23 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { t as parser } from "./rss-parser-Dv4dw4PQ.mjs";
import { load } from "cheerio";
//#region lib/routes/engadget/home.ts
const route = {
path: "/",
categories: ["new-media"],
example: "/engadget",
radar: [{ source: ["www.engadget.com"] }],
name: "Home",
maintainers: ["JamesWDGu", "KeiLongW"],
handler,
url: "www.engadget.com"
};
async function handler() {
const feed = await parser.parseURL("https://www.engadget.com/rss.xml");
const items = await Promise.all(feed.items.map((item) => cache_default.tryGet(item.link, async () => {
const $ = load(await rofetch(item.link));
const article = $("article");
article.find("ul.breadcrumbs, .title-gallery, .subtitle, .byline-container").remove();
article.find("img.lazyload").each((_, el) => {
$(el).attr("src", $(el).data("lazy-src"));
});
return {
title: item.title,
description: article.html(),
pubDate: item.pubDate,
link: item.link,
author: item.author
};
})));
return {
title: feed.title,
link: feed.link,
description: feed.description,
language: feed.language,
item: items
};
}
//#endregion
export { route };