RSSHub/lib/v2/techflowpost/express.js

34 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
import { unescapeAll } from 'markdown-it/lib/common/utils.mjs';
module.exports = async (ctx) => {
const rootUrl = 'https://www.techflowpost.com';
const apiRootUrl = 'https://data.techflowpost.com';
const currentUrl = `${rootUrl}/express`;
const apiUrl = `${apiRootUrl}/api/pc/express/all?pageIndex=0&pageSize=${ctx.req.query('limit') ?? 50}`;
const response = await got({
method: 'post',
url: apiUrl,
json: {
createTime: [],
},
});
const items = response.data.content.map((item) => ({
title: item.title,
link: `${rootUrl}/express/${item.id}`,
category: item.tags?.split('') ?? [],
pubDate: timezone(parseDate(item.createTime), +8),
description: unescapeAll(item.content),
}));
ctx.set('data', {
title: '深潮TechFlow - 快讯',
link: currentUrl,
item: items,
});
};