pds dash for shimaenaga.veryroundbird.house (based off of pds.witchcraft.systems)

add favicons, start adding in guestbook

+43 -3
+10 -2
src/App.svelte
··· 2 2 import PostComponent from "./lib/PostComponent.svelte"; 3 3 import AccountComponent from "./lib/AccountComponent.svelte"; 4 4 import InfiniteLoading from "svelte-infinite-loading"; 5 - import { getNextPosts, Post, getAllMetadataFromPds } from "./lib/pdsfetch"; 5 + import { getNextPosts, Post, getAllMetadataFromPds, fetchGuestbookPosts } from "./lib/pdsfetch"; 6 6 import { Config } from "../config"; 7 7 const accountsPromise = getAllMetadataFromPds(); 8 8 import { onMount } from "svelte"; 9 9 10 10 let posts: Post[] = []; 11 + let guestbookPosts: Post[] = []; 11 12 12 13 let hue: number = 1; 13 14 const cycleColors = async () => { ··· 34 35 getNextPosts().then((initialPosts) => { 35 36 posts = initialPosts; 36 37 }); 38 + fetchGuestbookPosts().then((gbPosts) => { 39 + guestbookPosts = gbPosts; 40 + console.log(gbPosts); 41 + }); 37 42 }); 38 43 // Infinite loading function 39 44 const onInfinite = ({ ··· 88 93 <div id="guestbookContents" popover> 89 94 <div id="signInfo">You can sign the guestbook <a href="{Config.GUESTBOOK_POST}" target="_blank">here</a>!</div> 90 95 <div id="guestbookPosts"> 91 - 96 + {#each guestbookPosts as postObject} 97 + <div class="guestbookPost"> 98 + </div> 99 + {/each} 92 100 </div> 93 101 </div> 94 102 </div>
+33 -1
src/lib/pdsfetch.ts
··· 359 359 } 360 360 }; 361 361 362 - export { getAllMetadataFromPds, getNextPosts, Post }; 362 + const convertUri = (uri: string) => { 363 + if (uri.startsWith("at://")) { 364 + return uri; 365 + } 366 + 367 + if (uri.includes("bsky.app/profile/")) { 368 + const match = uri.match(/profile\/([\w.]+)\/post\/([\w]+)/); 369 + if (match) { 370 + const [, did, postId] = match; 371 + return `at://${did}/app.bsky.feed.post/${postId}` as At.Did; 372 + } 373 + } 374 + 375 + this.error = "Invalid Bluesky post URL format"; 376 + return null; 377 + } 378 + 379 + const fetchGuestbookPosts = async () => { 380 + try { 381 + const { data } = await rpc.get("app.bsky.feed.getPostThread", { 382 + params: { 383 + uri: convertUri(Config.GUESTBOOK_POST) 384 + } 385 + }); 386 + 387 + return data.records as ComAtprotoRepoListRecords.Record[]; 388 + } catch (e) { 389 + console.error(`Error fetching replies for ${did}. Are you sure this is a Bluesky post?`, e); 390 + return null; 391 + } 392 + } 393 + 394 + export { getAllMetadataFromPds, getNextPosts, Post, fetchGuestbookPosts }; 363 395 export type { AccountMetadata };