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`;