this repo has no description
1
fork

Configure Feed

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

Retrieve and display BookHive book data

modamo-gh ba247a90 074bb407

+41 -5
+36 -1
app/book/[bookID]/page.tsx
··· 1 1 import Header from "@/components/Header"; 2 + import { getSession } from "@/lib/auth/session"; 3 + import { Agent } from "@atproto/api"; 4 + import { redirect } from "next/navigation"; 2 5 3 - const Book = () => { 6 + const Book = async ({ params }) => { 7 + const { bookID } = await params; 8 + 9 + const session = await getSession(); 10 + 11 + if (!session) { 12 + redirect("/"); 13 + } 14 + 15 + const agent = new Agent(session); 16 + 17 + let book; 18 + 19 + try { 20 + const response = await agent.com.atproto.repo.listRecords({ 21 + collection: "buzz.bookhive.book", 22 + limit: 100, 23 + repo: session.did 24 + }); 25 + 26 + book = response.data.records.find( 27 + (record) => record.value.hiveId === `bk_${bookID}` 28 + ); 29 + } catch (error) { 30 + console.error("Error fetching book:", error); 31 + } 32 + 4 33 return ( 5 34 <> 6 35 <Header /> 36 + <div className="gap-4 grid grid-cols-2 row-span-9"> 37 + <div className="bg-emerald-900 col-span-1 p-4 rounded-2xl"> 38 + <p>{JSON.stringify(book)}</p> 39 + </div> 40 + <div className="bg-emerald-900 col-span-1 p-4 rounded-2xl"></div> 41 + </div> 7 42 </> 8 43 ); 9 44 };
+2 -2
app/library/page.tsx
··· 17 17 let books; 18 18 19 19 try { 20 - const booksResponse = await agent.com.atproto.repo.listRecords({ 20 + const response = await agent.com.atproto.repo.listRecords({ 21 21 collection: "buzz.bookhive.book", 22 22 limit: 100, 23 23 repo: session.did 24 24 }); 25 25 26 - books = booksResponse.data.records.filter( 26 + books = response.data.records.filter( 27 27 (book) => 28 28 book.value.status === "buzz.bookhive.defs#reading" || 29 29 book.value.status === "buzz.bookhive.defs#wantToRead"
+3 -2
components/Header.tsx
··· 12 12 13 13 const agent = new Agent(session); 14 14 15 - let profile; 16 - 15 + let profile; 16 + 17 17 try { 18 18 const response = await agent.getProfile({ actor: session.did }); 19 19 ··· 21 21 } catch (error) { 22 22 console.error("Error loading profile:", error); 23 23 } 24 + 24 25 return ( 25 26 <header className="bg-emerald-900 flex items-center justify-between p-4 rounded-2xl row-span-1"> 26 27 <h1 className="text-amber-100 text-4xl">bambü</h1>