rsshub
Version:
Make RSS Great Again!
26 lines (25 loc) • 937 B
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { load } from "cheerio";
//#region lib/routes/ruby-china/utils.ts
const RUBY_CHINA_HOST = "https://ruby-china.org";
async function loadAndParseTopic(link) {
const $ = load(await rofetch(link));
return {
title: $(".topic-detail .title").text(),
link,
author: $(".topic-detail .user-name").text(),
guid: link,
description: $(".topic-detail .card-body").html(),
pubDate: parseDate($(".topic-detail .timeago").attr("title"))
};
}
function processTopics2Feed(list) {
return Promise.all(list.map((item) => {
const itemUrl = new URL(load(item)(".title a").attr("href"), RUBY_CHINA_HOST).href;
return cache_default.tryGet(itemUrl, () => loadAndParseTopic(itemUrl));
}));
}
//#endregion
export { processTopics2Feed as n, RUBY_CHINA_HOST as t };