From 0091092ecafbfb8c637f06bd8fc9bb3e95f15ed9 Mon Sep 17 00:00:00 2001 From: serenity <98162476+NekoDrone@users.noreply.github.com> Date: Mon, 20 Apr 2026 04:48:15 +0800 Subject: [PATCH] feat: embeddable bluesky post --- src/components/Bsky/Post.astro | 78 ++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/components/Bsky/Post.astro diff --git a/src/components/Bsky/Post.astro b/src/components/Bsky/Post.astro new file mode 100644 index 0000000..c110b7f --- /dev/null +++ b/src/components/Bsky/Post.astro @@ -0,0 +1,78 @@ +--- +import TablerBrandBluesky from "../Icons/TablerBrandBluesky.astro"; + +interface Props { + pdsUrl: string; + repoDid: string; + rkey: string; +} + +const { pdsUrl, repoDid, rkey } = Astro.props; +const postRes = await fetch( + `${pdsUrl}/xrpc/com.atproto.repo.getRecord?repo=${repoDid}&collection=app.bsky.feed.post&rkey=${rkey}` +); +const profileRes = await fetch( + `${pdsUrl}/xrpc/com.atproto.repo.getRecord?repo=${repoDid}&collection=app.bsky.actor.profile&rkey=self` +); +const miniDocRes = await fetch( + `https://slingshot.microcosm.blue/xrpc/blue.microcosm.identity.resolveMiniDoc?identifier=${repoDid}` +); + +const postData = (await postRes.json()) as { + uri: string; + cid: string; + value: { text: string }; +}; + +const profileData = (await profileRes.json()) as { + uri: string; + cid: string; + value: { + avatar: { ref: { $link: string }; mimeType: string }; + banner: { ref: { $link: string }; mimeType: string }; + displayName: string; + }; +}; + +const miniDocData = (await miniDocRes.json()) as { + did: string; + handle: string; +}; + +const avatarBlobSrc = `${pdsUrl}/xrpc/com.atproto.sync.getBlob?did=${repoDid}&cid=${profileData.value.avatar.ref.$link}`; +const bannerBlobSrc = `${pdsUrl}/xrpc/com.atproto.sync.getBlob?did=${repoDid}&cid=${profileData.value.banner.ref.$link}`; + +const { value } = postData; +const { text: postText } = value; +--- + +
+
+ + +
+ + {profileData.value.displayName} + + @{miniDocData.handle} + +
+
+ +
+ {postText} +
-- 2.51.2