Files
RSSHub/lib/routes/mihoyo/bbs/utils.ts
T
DIYgod 83e701b592 feat: compile ts through tsdown (#18908)
* feat: build ts via tsdown

* feat: exec tsdown

* fix

* fix

* fix

* feat: use tsdown shims

* chore: run rolldown lifecycle script

* fix: use shims

---------
2025-04-22 22:29:11 +08:00

35 lines
1.0 KiB
TypeScript

import { art } from '@/utils/render';
import path from 'node:path';
import { parseDate } from '@/utils/parse-date';
const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.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;
}
}
const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean));
const pubDate = parseDate(e.post.created_at * 1000);
const upvotes = e.stat.like_num;
const comments = e.stat.reply_num;
return {
author,
title,
link,
description,
pubDate,
upvotes,
comments,
};
};
export { post2item };