Fix Bluesky feed handle normalization for social activity widget
This commit is contained in:
+11
-5
@@ -4,15 +4,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import EleventyFetch from "@11ty/eleventy-fetch";
|
import EleventyFetch from "@11ty/eleventy-fetch";
|
||||||
import { BskyAgent } from "@atproto/api";
|
|
||||||
|
|
||||||
export default async function () {
|
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 {
|
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)
|
// 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`;
|
const feedUrl = `https://public.api.bsky.app/xrpc/app.bsky.feed.getAuthorFeed?actor=${handle}&limit=10`;
|
||||||
|
|
||||||
|
|||||||
@@ -4,15 +4,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import EleventyFetch from "@11ty/eleventy-fetch";
|
import EleventyFetch from "@11ty/eleventy-fetch";
|
||||||
import { BskyAgent } from "@atproto/api";
|
|
||||||
|
|
||||||
export default async function () {
|
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 {
|
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)
|
// 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`;
|
const feedUrl = `https://public.api.bsky.app/xrpc/app.bsky.feed.getAuthorFeed?actor=${handle}&limit=10`;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user