rsshub
Version:
Make RSS Great Again!
78 lines (76 loc) • 2.41 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { load } from "cheerio";
//#region lib/routes/huggingface/blog-community.ts
const route = {
path: "/blog-community/:sort?",
categories: ["programming"],
example: "/huggingface/blog-community",
parameters: { sort: {
description: "Sort by trending or recent",
default: "trending",
options: [{
value: "trending",
label: "Trending"
}, {
value: "recent",
label: "Recent"
}]
} },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["huggingface.co/blog/community", "huggingface.co/"] }],
name: "Community Articles",
maintainers: ["yuguorui"],
handler,
url: "huggingface.co/blog/community"
};
let Type = /* @__PURE__ */ function(Type$1) {
Type$1["Org"] = "org";
Type$1["User"] = "user";
return Type$1;
}({});
let Status = /* @__PURE__ */ function(Status$1) {
Status$1["Published"] = "published";
return Status$1;
}({});
async function handler(ctx) {
const { sort = "trending" } = ctx.req.param();
const { body: response } = await got_default(`https://huggingface.co/blog/community?sort=${sort}`);
const data = load(response)("div[data-target=\"CommunityBlogsContainer\"]").attr("data-props");
if (!data) throw new Error("Failed to fetch data from Huggingface Community Articles");
const lists = JSON.parse(data).posts.map((item) => ({
title: item.title,
link: `https://huggingface.co/blog/${item.authorData.name}/${item.slug}`,
pubDate: parseDate(item.publishedAt),
author: item.authorData.name
}));
return {
title: "Huggingface Community Articles",
link: "https://huggingface.co/blog/community",
item: await Promise.all(lists.map((item) => cache_default.tryGet(item.link, async () => {
const { body: response$1 } = await got_default(item.link);
const $ = load(response$1);
$(".mb-4, h1, .mb-6, .not-prose").remove();
return {
...item,
description: $(".blog-content").html()
};
})))
};
}
//#endregion
export { Status, Type, route };