Fix Bluesky feed handle normalization for social activity widget

This commit is contained in:
svemagie
2026-03-09 22:46:06 +01:00
parent cd1c933f7e
commit a675908497
2 changed files with 22 additions and 10 deletions

View File

@@ -4,15 +4,21 @@
*/
import EleventyFetch from "@11ty/eleventy-fetch";
import { BskyAgent } from "@atproto/api";
export default async function () {
const handle = process.env.BLUESKY_HANDLE || "";
const rawHandle = (process.env.BLUESKY_HANDLE || "")
.trim()
.replace(/^@+/, "");
const handle =
rawHandle && !rawHandle.includes(".") && !rawHandle.startsWith("did:")
? `${rawHandle}.bsky.social`
: rawHandle;
if (!handle) {
return [];
}
try {
// Create agent and resolve handle to DID
const agent = new BskyAgent({ service: "https://bsky.social" });
// Get the author's feed using public API (no auth needed for public posts)
const feedUrl = `https://public.api.bsky.app/xrpc/app.bsky.feed.getAuthorFeed?actor=${handle}&limit=10`;

View File

@@ -4,15 +4,21 @@
*/
import EleventyFetch from "@11ty/eleventy-fetch";
import { BskyAgent } from "@atproto/api";
export default async function () {
const handle = process.env.BLUESKY_HANDLE || "";
const rawHandle = (process.env.BLUESKY_HANDLE || "")
.trim()
.replace(/^@+/, "");
const handle =
rawHandle && !rawHandle.includes(".") && !rawHandle.startsWith("did:")
? `${rawHandle}.bsky.social`
: rawHandle;
if (!handle) {
return [];
}
try {
// Create agent and resolve handle to DID
const agent = new BskyAgent({ service: "https://bsky.social" });
// Get the author's feed using public API (no auth needed for public posts)
const feedUrl = `https://public.api.bsky.app/xrpc/app.bsky.feed.getAuthorFeed?actor=${handle}&limit=10`;