library/pages/index.tsx

35 lines
676 B
TypeScript
Raw Normal View History

2021-11-16 22:38:00 -05:00
import React from "react";
2021-10-30 19:44:32 -04:00
import { getBook, getAllBooks, DetailedBook, SimpleBook } from "../lib/books";
2021-10-30 19:44:32 -04:00
export default function Home(props: Props) {
return (
<div>
<ul>
{props.books.map((book, idx) => {
return (
<li key={`${idx}_${book.id}`}>
{book.id}; {book.title}; {book.authors}; {book.isbn}
</li>
);
})}
</ul>
<p>{props.book.title}</p>
</div>
);
}
interface Props {
book: DetailedBook;
books: SimpleBook[];
}
export async function getServerSideProps() {
return {
props: {
book: await getBook(44),
books: await getAllBooks(),
},
};
}