Files
RSSHub/lib/routes/afdian/dynamic.js
T
jiechusandgithub-actions[bot] 1121f8c0a0 fix(route): 添加若干路由的图标 (#9301)
* cover

* add bilibili dynamic image

* fix bilibili dynamic

* fix bilibili dynamic x2

* style: auto format

* add afdian image

* style: auto format

* fix git

* style: auto format

* add zhihu activities image

* optimize zhihu activities title

* optimize TG channel title

* style: auto format

* optimized reg

* optimized reg

* optimized reg

* optimized reg

* optimized reg

* optimized reg

* optimized reg

* FIX betterTitle

* FIX betterTitle x2

* FIX betterTitle x3

* FIX betterTitle x4

* FIX betterTitle x5

* Optimize betterTitle preprocessed HTML tags

* FIX regular

* add IThome image

* Update channel.js

* Excluded Content

* Excluded Content

* 解决 DeepScan

* 解决 DeepScan

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-11 19:39:23 +08:00

37 lines
1.2 KiB
JavaScript

const got = require('@/utils/got');
module.exports = async (ctx) => {
const url_slug = ctx.params.uid.replace('@', '');
const baseUrl = 'https://afdian.net';
const userInfoRes = await got(`${baseUrl}/api/user/get-profile-by-slug`, {
searchParams: {
url_slug,
},
});
const userInfo = userInfoRes.data.data.user;
const { user_id, name, avatar } = userInfo;
const dynamicRes = await got(`${baseUrl}/api/post/get-list`, {
searchParams: {
type: 'old',
user_id,
},
});
const list = dynamicRes.data.data.list.map((item) => {
const { publish_time, title, content, pics = [], post_id } = item;
return {
title,
description: [content, pics.map((url) => `<img src="${url}"/>`).join('')].filter((str) => !!str).join('<br/>'),
link: `${baseUrl}/p/${post_id}`,
pubDate: new Date(Number(publish_time) * 1000).toUTCString(),
};
});
ctx.state.data = {
title: `${name}的爱发电动态`,
description: `${name}的爱发电动态`,
image: avatar,
link: `${baseUrl}/@${url_slug}`,
item: list,
};
};