-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from spencer-rafada/spencer/details-page-pagina…
…tion Dynamic Books Page
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
} |