Show Goodreads books on about page

This commit is contained in:
SirBlob committed 2026-11-01 20:46:34 -05:00
1 parent a2ffd45442
commit 0cfebc385f
12 files changed
+673 -213

No files matched your search

-24
View File
@@ -1,24 +0,0 @@
import type { Book } from '#lib/content';
const coverBaseUrl = 'https://covers.openlibrary.org/b/isbn';
const bookPageBaseUrl = 'https://openlibrary.org/isbn';
function cleanIsbn(isbn: string): string {
return isbn.replace(/[^0-9X]/gi, '');
}
export function bookCover(book: Book): string | null {
return book.isbn ? `${coverBaseUrl}/${cleanIsbn(book.isbn)}-L.jpg?default=false` : null;
}
export function bookLink(book: Book): string | null {
if (book.url) return book.url;
return book.isbn ? `${bookPageBaseUrl}/${cleanIsbn(book.isbn)}` : null;
}
export function sortBooks(books: Book[]): Book[] {
return [...books].sort((first, second) => {
const readingOrder = Number(second.status === 'reading') - Number(first.status === 'reading');
return readingOrder || (second.rating ?? 0) - (first.rating ?? 0);
});
}