UNPKG

rsshub

Version:
34 lines (32 loc) 1.06 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import path from "node:path"; //#region lib/routes/mihoyo/bbs/utils.ts init_esm_shims(); const renderDescription = (description, images) => art(path.join(__dirname, "templates/description-d08e0099.art"), { description, images }); const post2item = (e) => { const author = e.user.nickname; const title = e.post.subject; const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`; let describe = e.post.content || ""; try { describe = JSON.parse(e.post.content).describe; } catch (error) { if (!(error instanceof SyntaxError)) throw error; } return { author, title, link, description: renderDescription(describe || "", [...new Set([e.post.cover, ...e.post.images])].filter(Boolean)), pubDate: parseDate(e.post.created_at * 1e3), upvotes: e.stat.like_num, comments: e.stat.reply_num }; }; //#endregion export { post2item as t };