rsshub
Version:
Make RSS Great Again!
75 lines (73 loc) • 2.42 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, n as getFeed, r as getFeedGenerator } from "./utils-BHYHGgGl.mjs";
import path from "node:path";
//#region lib/routes/bsky/feeds.ts
init_esm_shims();
const route = {
path: "/profile/:handle/feed/:space/:routeParams?",
categories: ["social-media"],
view: ViewType.SocialMedia,
example: "/bsky.app/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, cache_default.tryGet);
const uri = `at://${DID}/app.bsky.feed.generator/${space}`;
const profile = await getFeedGenerator(uri, cache_default.tryGet);
const feeds = await getFeed(uri, cache_default.tryGet);
const items = feeds.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,
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 };