rsshub
Version:
Make RSS Great Again!
45 lines (43 loc) • 1.47 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
//#region lib/routes/afdian/dynamic.ts
const route = {
path: "/dynamic/:uid?",
categories: ["other"],
example: "/afdian/dynamic/@afdian",
parameters: { uid: "用户id,用户动态页面url里可找到" },
name: "用户动态",
maintainers: ["sanmmm"],
handler
};
async function handler(ctx) {
const url_slug = ctx.req.param("uid").replace("@", "");
const baseUrl = "https://afdian.com";
const { user_id, name, avatar } = (await got_default(`${baseUrl}/api/user/get-profile-by-slug`, { searchParams: { url_slug } })).data.data.user;
const list = (await got_default(`${baseUrl}/api/post/get-list`, { searchParams: {
type: "old",
user_id
} })).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: (/* @__PURE__ */ new Date(Number(publish_time) * 1e3)).toUTCString()
};
});
return {
title: `${name}的爱发电动态`,
description: `${name}的爱发电动态`,
image: avatar,
link: `${baseUrl}/@${url_slug}`,
item: list
};
}
//#endregion
export { route };