rsshub
Version:
Make RSS Great Again!
88 lines (84 loc) • 3.02 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import { t as ViewType } from "./types-D84BRIt4.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import "./got-KxxWdaxq.mjs";
import { a as resolveHandle, i as getProfile, t as getAuthorFeed } from "./utils-BHYHGgGl.mjs";
import path from "node:path";
import querystring from "node:querystring";
//#region lib/routes/bsky/posts.ts
init_esm_shims();
const route = {
path: "/profile/:handle/:routeParams?",
categories: ["social-media"],
view: ViewType.SocialMedia,
example: "/bsky/profile/bsky.app",
parameters: {
handle: "User handle, can be found in URL",
routeParams: "Filter parameter, Use filter to customize content types"
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["bsky.app/profile/:handle"] }],
name: "Post",
maintainers: ["TonyRL"],
handler,
description: `
| Filter Value | Description |
|--------------|-------------|
| posts_with_replies | Includes Posts, Replies, and Reposts |
| posts_no_replies | Includes Posts and Reposts, without Replies |
| posts_with_media | Shows only Posts containing media |
| posts_and_author_threads | Shows Posts and Threads, without Replies and Reposts |
Default value for filter is \`posts_and_author_threads\` if not specified.
Example:
- \`/bsky/profile/bsky.app/filter=posts_with_replies\``
};
async function handler(ctx) {
const handle = ctx.req.param("handle");
const filter = querystring.parse(ctx.req.param("routeParams")).filter || "posts_and_author_threads";
const DID = await resolveHandle(handle, cache_default.tryGet);
const profile = await getProfile(DID, cache_default.tryGet);
const authorFeed = await getAuthorFeed(DID, filter, cache_default.tryGet);
const items = authorFeed.feed.map(({ post }) => ({
title: post.record.text.split("\n")[0],
description: art(path.join(__dirname, "templates/post-7b0043bb.art"), {
text: post.record.text.replaceAll("\n", "<br>"),
embed: post.embed
}),
author: post.author.displayName,
pubDate: parseDate(post.record.createdAt),
link: `https://bsky.app/profile/${post.author.handle}/post/${post.uri.split("app.bsky.feed.post/")[1]}`,
upvotes: post.likeCount,
comments: post.replyCount
}));
ctx.set("json", {
DID,
profile,
authorFeed
});
return {
title: `${profile.displayName} (@${profile.handle}) — Bluesky`,
description: profile.description?.replaceAll("\n", " "),
link: `https://bsky.app/profile/${profile.handle}`,
image: profile.avatar,
icon: profile.avatar,
logo: profile.avatar,
item: items,
allowEmpty: true
};
}
//#endregion
export { route };