···55import config from "@/../blog.config";
6677const handler = simpleFetchHandler({
88+ // Simply hit up the Bluesky API
89 service: "https://public.api.bsky.app"
910});
1011const rpc = new Client({ handler });
···1415 | AppBskyFeedDefs.BlockedPost
1516 | AppBskyFeedDefs.NotFoundPost;
16171818+/**
1919+ * Fetch the first 10 replies to a post
2020+ * @param cid
2121+ * @returns
2222+ */
1723export async function getBskyReplies(cid: string) {
1824 // uri should be in format: at://did:plc:xxx/app.bsky.feed.post/xxxxx
1925 const uri: ResourceUri = `at://${config.authorDid}/app.bsky.feed.post/${cid}`;
···2127 const { ok, data } = await rpc.get("app.bsky.feed.getPostThread", {
2228 params: {
2329 uri,
2424- depth: 10
3030+ depth: 6 // default
2531 }
2632 });
27332834 if (!ok) {
3535+ // Handle fetch errors as 'not found'. Could be cleaner, but works just fine.
2936 console.error("Error fetching thread:", data.error);
3037 return { $type: "app.bsky.feed.defs#notFoundPost" };
3138 }
···3744 return { $type: "app.bsky.feed.defs#notFoundPost" };
3845}
39464747+/**
4848+ * Extract post id from an atproto uri
4949+ * @param uri The atproto uri, such as at://did:plc:user/app.bsky.feed.post/xxxxx`
5050+ * @returns The post id
5151+ */
4052export function extractPostId(uri: ResourceUri) {
4153 if (uri.includes("app.bsky.feed.post")) {
4254 const parts = uri.split("/");