Skip to content

Commit

Permalink
Merge pull request #7 from spencer-rafada/spencer/details-page-pagina…
Browse files Browse the repository at this point in the history
…tion

Dynamic Books Page
  • Loading branch information
spencer-rafada authored Jan 31, 2024
2 parents 6cc6cc8 + 304c405 commit b2b90d6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/app/books/[olid]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'

type Props = {
params: { olid: string }
}

// This function is called during the build (build time) for GitHub Actions
export async function generateStaticParams() {
const books = await fetch(
'https://openlibrary.org/search.json?q=the+hunger+games&fields=key,title,author_name,editions,isbn,publish_date,ratings_average,ratings_count,publisher,author_key,language,first_sentence,person,place,subject'
).then((res) => res.json())
const book = books.docs.map((book: any) => ({
olid: book.editions?.docs?.[0]?.key?.replace('/books/', ''),
}))

return book
}

export default function DetailsPage({ params }: Props) {
return <div>{params.olid}</div>
}

0 comments on commit b2b90d6

Please sign in to comment.