UNPKG

rsshub

Version:
39 lines (38 loc) 1.19 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { load } from "cheerio"; //#region lib/routes/leemeng/index.ts const route = { path: "/", categories: ["blog"], example: "/leemeng", name: "blog", maintainers: ["xyqfer"], handler }; async function handler() { const url = "https://leemeng.tw/blog.html"; const response = await rofetch(url); const $ = load(response); return { title: "LeeMeng - 部落格", link: url, item: $("article").toArray().map((elem) => { const $link = $(elem).find("[rel=\"bookmark\"]"); const title = $link.text(); const link = new URL($link.attr("href"), url).href; const summary = $(elem).children("p").toArray().map((p) => $(p).text()).find(Boolean); const image = $(elem).find("img").attr("src"); return { title, link, description: image ? `<img src="${image}"><p>${summary}</p>` : summary, image, category: $(elem).find("[rel=\"tag\"]").toArray().map((tag) => $(tag).text()), pubDate: parseDate($(elem).find(".blog-date a, .page-header__date").text().trim(), "YYYY-MM-DD (ddd)") }; }) }; } //#endregion export { route };