Add books and manga to about page

This commit is contained in:
SirBlob committed 2026-11-01 18:42:28 -05:00
1 parent 87079dcb88
commit 90d61c48e2
13 files changed
+674 -348

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
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);
});
}