diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 24810b3..104a1f5 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1470,7 +1470,7 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "mangalord" -version = "0.51.1" +version = "0.51.2" dependencies = [ "anyhow", "argon2", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index dbfbc5d..61dcc0b 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mangalord" -version = "0.51.1" +version = "0.51.2" edition = "2021" default-run = "mangalord" diff --git a/frontend/e2e/reader.spec.ts b/frontend/e2e/reader.spec.ts index 78ce8aa..f9a346d 100644 --- a/frontend/e2e/reader.spec.ts +++ b/frontend/e2e/reader.spec.ts @@ -120,7 +120,7 @@ test('manga overview shows title, cover, and a chapter list', async ({ page }) = await expect(page.getByTestId('manga-title')).toHaveText('Berserk'); await expect(page.getByTestId('manga-author')).toContainText('Kentaro Miura'); await expect(page.getByTestId('manga-cover')).toBeVisible(); - await expect(page.getByTestId('chapter-list')).toContainText('Chapter 1'); + await expect(page.getByTestId('chapter-list')).toContainText('The Brand'); await expect(page.getByTestId('bookmark-signin')).toBeVisible(); }); diff --git a/frontend/package.json b/frontend/package.json index ea84563..1aa6fc9 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "mangalord-frontend", - "version": "0.51.1", + "version": "0.51.2", "private": true, "type": "module", "scripts": { diff --git a/frontend/src/lib/api/chapters.test.ts b/frontend/src/lib/api/chapters.test.ts index 37d2779..ec5faa3 100644 --- a/frontend/src/lib/api/chapters.test.ts +++ b/frontend/src/lib/api/chapters.test.ts @@ -11,7 +11,8 @@ import { listChapters, getChapter, getChapterPages, - createChapter + createChapter, + chapterLabel } from './chapters'; function ok(body: unknown): Response { @@ -129,6 +130,18 @@ describe('chapters api client', () => { } }); + describe('chapterLabel', () => { + it('returns the site title verbatim when present', () => { + expect(chapterLabel({ number: 7, title: 'Ch.7 : Official' })).toBe( + 'Ch.7 : Official' + ); + }); + + it('falls back to "Chapter {number}" when title is null', () => { + expect(chapterLabel({ number: 3, title: null })).toBe('Chapter 3'); + }); + }); + it('getChapterPages unwraps the {pages} envelope into the array', async () => { fetchSpy.mockResolvedValueOnce( ok({ diff --git a/frontend/src/lib/api/chapters.ts b/frontend/src/lib/api/chapters.ts index 2247c84..42cc8a6 100644 --- a/frontend/src/lib/api/chapters.ts +++ b/frontend/src/lib/api/chapters.ts @@ -14,6 +14,10 @@ export type ChaptersPage = { page: Page; }; +export function chapterLabel(c: Pick): string { + return c.title ?? `Chapter ${c.number}`; +} + export type ListOptions = { limit?: number; offset?: number; diff --git a/frontend/src/routes/manga/[id]/+page.svelte b/frontend/src/routes/manga/[id]/+page.svelte index 33e4fcc..94b6bff 100644 --- a/frontend/src/routes/manga/[id]/+page.svelte +++ b/frontend/src/routes/manga/[id]/+page.svelte @@ -10,6 +10,7 @@ type TagRef } from '$lib/api/mangas'; import { resyncManga } from '$lib/api/admin'; + import { chapterLabel } from '$lib/api/chapters'; import { listTags, type Tag } from '$lib/api/tags'; import { session } from '$lib/session.svelte'; import Chip from '$lib/components/Chip.svelte'; @@ -45,6 +46,11 @@ continueChapter?.number ?? readProgress?.chapter_number ?? null ); const continueChapterTitle = $derived(continueChapter?.title ?? null); + const continueLabel = $derived( + continueChapterNumber != null + ? chapterLabel({ number: continueChapterNumber, title: continueChapterTitle }) + : null + ); const authors = $derived(manga.authors); const genres = $derived(manga.genres); @@ -431,7 +437,7 @@ > Continue reading - Chapter {continueChapterNumber}{#if continueChapterTitle}: {continueChapterTitle}{/if} + {continueLabel} {#if readProgress && readProgress.page > 1} — page {readProgress.page} {/if} @@ -445,7 +451,7 @@ {#each chapters as c (c.id)}
  • - Chapter {c.number}{#if c.title}: {c.title}{/if} + {chapterLabel(c)} ({c.page_count} pages)
  • diff --git a/frontend/src/routes/manga/[id]/chapter/[chapter_id]/+page.svelte b/frontend/src/routes/manga/[id]/chapter/[chapter_id]/+page.svelte index bdcf968..8c4240c 100644 --- a/frontend/src/routes/manga/[id]/chapter/[chapter_id]/+page.svelte +++ b/frontend/src/routes/manga/[id]/chapter/[chapter_id]/+page.svelte @@ -5,6 +5,7 @@ import { GAP_PX, type ReaderPageGap } from '$lib/api/preferences'; import { preferences } from '$lib/preferences.svelte'; import { updateReadProgress } from '$lib/api/read_progress'; + import { chapterLabel } from '$lib/api/chapters'; import { resyncChapter } from '$lib/api/admin'; import { readerFullscreen } from '$lib/reader-fullscreen.svelte'; import { session } from '$lib/session.svelte'; @@ -28,9 +29,7 @@ const gapPx = $derived(GAP_PX[preferences.readerPageGap]); const pageTitle = $derived( - chapter.title - ? `Mangalord | ${manga.title} · Ch. ${chapter.number}: ${chapter.title}` - : `Mangalord | ${manga.title} · Ch. ${chapter.number}` + `Mangalord | ${manga.title} · ${chapterLabel(chapter)}` ); // Prev/next chapter computed from the chapter list. listChapters @@ -474,7 +473,7 @@ > {#each sortedChapters as c (c.id)} {/each} @@ -685,7 +684,7 @@