diff --git a/content/about.json b/content/about.json index d8f0dd0..098987d 100644 --- a/content/about.json +++ b/content/about.json @@ -75,5 +75,6 @@ { "name": "Avatar: The Way of Water", "rating": 10, "url": "https://www.imdb.com/title/tt1630029/" }, { "name": "Avatar: Fire and Ash", "rating": 8, "url": "https://www.imdb.com/title/tt1757678/" }, { "name": "Blade Runner 2049", "rating": 10, "url": "https://www.imdb.com/title/tt1856101/" } - ] + ], + "books": [] } diff --git a/src/lib/anilist/types.ts b/src/lib/anilist/types.ts new file mode 100644 index 0000000..8526ee1 --- /dev/null +++ b/src/lib/anilist/types.ts @@ -0,0 +1,38 @@ +export type AniListMediaType = 'ANIME' | 'MANGA'; + +export interface AniListEntry { + id: number; + title: string; + url: string; + cover: string; + score: number; + progress: number; + total: number | null; +} + +export interface AniListStat { + label: string; + value: string; +} + +export interface AniListStatusCount { + status: string; + label: string; + count: number; +} + +export interface AniListProfile { + mediaType: AniListMediaType; + name: string; + profileUrl: string; + listUrl: string; + stats: AniListStat[]; + statusCounts: AniListStatusCount[]; + current: AniListEntry[]; + currentLabel: string; + progressUnit: string; + totalUnit: string; + topRated: AniListEntry[]; + planning: AniListEntry[]; + completedCount: number; +} diff --git a/src/lib/anime/types.ts b/src/lib/anime/types.ts deleted file mode 100644 index 75c9482..0000000 --- a/src/lib/anime/types.ts +++ /dev/null @@ -1,31 +0,0 @@ -export interface AnimeEntry { - id: number; - title: string; - url: string; - cover: string; - score: number; - progress: number; - episodes: number | null; -} - -export interface AnimeStats { - count: number; - episodesWatched: number; - daysWatched: number; -} - -export interface AnimeStatusCount { - status: string; - label: string; - count: number; -} - -export interface AnimeProfile { - name: string; - profileUrl: string; - stats: AnimeStats; - statusCounts: AnimeStatusCount[]; - watching: AnimeEntry[]; - topRated: AnimeEntry[]; - completedCount: number; -} diff --git a/src/lib/books/books.ts b/src/lib/books/books.ts new file mode 100644 index 0000000..89bba15 --- /dev/null +++ b/src/lib/books/books.ts @@ -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); + }); +} diff --git a/src/lib/components/about/AniListCoverGrid.svelte b/src/lib/components/about/AniListCoverGrid.svelte new file mode 100644 index 0000000..af135b4 --- /dev/null +++ b/src/lib/components/about/AniListCoverGrid.svelte @@ -0,0 +1,150 @@ + + +