From a67590849748b5afdc98435ef9a540c51a42f857 Mon Sep 17 00:00:00 2001 From: svemagie <869694+svemagie@users.noreply.github.com> Date: Mon, 9 Mar 2026 22:46:06 +0100 Subject: [PATCH] Fix Bluesky feed handle normalization for social activity widget --- _data/blueskyFeed.js | 16 +++++++++++----- theme/_data/blueskyFeed.js | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/_data/blueskyFeed.js b/_data/blueskyFeed.js index b0083bc..00e604b 100644 --- a/_data/blueskyFeed.js +++ b/_data/blueskyFeed.js @@ -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`; diff --git a/theme/_data/blueskyFeed.js b/theme/_data/blueskyFeed.js index b0083bc..00e604b 100644 --- a/theme/_data/blueskyFeed.js +++ b/theme/_data/blueskyFeed.js @@ -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`;