UNPKG

rsshub

Version:
63 lines (62 loc) 1.86 kB
import "./types-DNj6Etbg.mjs"; import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs"; import { a as resolveHandle, n as getFeed, o as renderPost, r as getFeedGenerator } from "./utils-BZJsG4qS.mjs"; //#region lib/routes/bsky/feeds.ts const route = { path: "/profile/:handle/feed/:space/:routeParams?", categories: ["social-media"], view: 1, example: "/bsky/profile/jaz.bsky.social/feed/cv:cat", parameters: { handle: "User handle, can be found in URL", space: "Space ID, can be found in URL" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "Feeds", maintainers: ["FerrisChi"], handler }; async function handler(ctx) { const handle = ctx.req.param("handle"); const space = ctx.req.param("space"); const DID = await resolveHandle(handle); const uri = `at://${DID}/app.bsky.feed.generator/${space}`; const profile = await getFeedGenerator(uri); const feeds = await getFeed(uri); const items = feeds.feed.map(({ post }) => ({ title: post.record.text.split("\n", 1)[0], description: renderPost({ 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/", 2)[1]}`, upvotes: post.likeCount, comments: post.replyCount })); ctx.set("json", { DID, profile, feeds }); return { title: `${profile.view.displayName} — Bluesky`, description: profile.view.description?.replaceAll("\n", " "), link: `https://bsky.app/profile/${handle}/feed/${space}`, image: profile.view.avatar, icon: profile.view.avatar, logo: profile.view.avatar, item: items, allowEmpty: true }; } //#endregion export { route };