Personal Site
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Accept record key in post to allow for linking to the original post

+22 -8
+20 -7
src/components/home/feeds/Feed.astro
··· 1 1 --- 2 2 import boxLR from "/assets/box-lr.png"; 3 3 import { socials } from "/site-config"; 4 - import { is } from "@atcute/lexicons"; 4 + import { is, type ResourceUri } from "@atcute/lexicons"; 5 5 import { AppBskyFeedPost } from "@atcute/bluesky"; 6 6 import Post, { type Author } from "./Post.astro"; 7 7 import { client } from "./atproto"; ··· 20 20 return "Error 500: Internal server error fetching this feed. Try refreshing the page"; 21 21 } 22 22 23 - let posts: { record: AppBskyFeedPost.Main; author: Author }[] = data.feed 23 + let posts: { 24 + record: AppBskyFeedPost.Main; 25 + author: Author; 26 + uri: ResourceUri; 27 + }[] = data.feed 24 28 // make sure it was by me (exclude reposts) 25 29 .filter((x) => x.post.author.did === socials.atproto.did) 26 30 // makes sure its not a reply ··· 38 42 handle: x.post.author.handle, 39 43 avatar: x.post.author.avatar, 40 44 }, 45 + uri: x.post.uri, 41 46 }; 42 47 }) 43 48 .filter((x) => x.record); ··· 48 53 <h2>Bluesky 🦋</h2> 49 54 <ul> 50 55 { 51 - posts.map((x) => ( 52 - <li> 53 - <Post post={x.record} author={x.author} /> 54 - </li> 55 - )) 56 + posts.map((x) => { 57 + const uriFragments = x.uri.match( 58 + new RegExp( 59 + "at:\/\/(?<did>did:(?:plc|web):[^\/]*)\/(?<nsid>[^\/]*)\/(?<rkey>.*)", 60 + ), 61 + ); 62 + let rkey: string = uriFragments?.groups?.rkey ?? ""; 63 + return ( 64 + <li> 65 + <Post post={x.record} author={x.author} {rkey} /> 66 + </li> 67 + ); 68 + }) 56 69 } 57 70 </ul> 58 71 </div>
+2 -1
src/components/home/feeds/Post.astro
··· 16 16 post: AppBskyFeedPost.Main; 17 17 author: Author; 18 18 nested?: boolean; 19 + rkey: string; 19 20 } 20 21 21 - const { post, author, nested = false } = Astro.props; 22 + const { post, author, nested = false, rkey } = Astro.props; 22 23 23 24 // resolve the pds. bit hacky but should work 24 25 const pds = await docResolver