rsshub
Version:
Make RSS Great Again!
72 lines (70 loc) • 2.25 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import "./config-MQ-7ebJ_.mjs";
import { t as ViewType } from "./types-gOySfSXJ.mjs";
import "./logger-C4avouvV.mjs";
import "./ofetch-DKl_Ma9g.mjs";
import { t as parseDate } from "./parse-date-r5WDWHno.mjs";
import "./is-worker-DESPicPc.mjs";
import { t as cache_default } from "./cache-SV6W5EPy.mjs";
import "./helpers-Bo4JQYdN.mjs";
import "./got-CO-ndVl2.mjs";
import { a as resolveHandle, n as getFeed, o as renderPost, r as getFeedGenerator } from "./utils-BsH3yvUa.mjs";
//#region lib/routes/bsky/feeds.ts
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: 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/")[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 };