Add chapter count badges, cover zoom, latest chapter button, and dismiss continue-reading cards
Some checks failed
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

- Home page book cards show downloaded chapter count (amber badge) via new CountChapters method
- Book page cover image is clickable to zoom into a fullscreen overlay; click anywhere to dismiss
- Book page shows a 'Latest Chapter' button for unstarted books linking to the last downloaded chapter
- Continue-reading cards on home page have a dismiss (×) button that removes progress from localStorage and slides the card out to the left
This commit is contained in:
Admin
2026-03-01 22:45:18 +05:00
parent 05a1cc04c0
commit 33b0ee4771
2 changed files with 114 additions and 2 deletions

View File

@@ -206,6 +206,25 @@ func (w *Writer) ListChapters(slug string) ([]ChapterInfo, error) {
return chapters, nil
}
// CountChapters returns the number of chapter markdown files on disk for slug.
// It is cheaper than ListChapters because it does not read file contents.
func (w *Writer) CountChapters(slug string) int {
bookDir := w.bookDir(slug)
volDirs, err := filepath.Glob(filepath.Join(bookDir, "vol-*"))
if err != nil {
return 0
}
count := 0
for _, vd := range volDirs {
rangeDirs, _ := filepath.Glob(filepath.Join(vd, "*-*"))
for _, rd := range rangeDirs {
files, _ := filepath.Glob(filepath.Join(rd, "chapter-*.md"))
count += len(files)
}
}
return count
}
// chapterTitle reads the first non-empty line of a markdown file and strips
// the leading "# " heading marker. Falls back to "Chapter N".
func chapterTitle(path string, n int) (title, date string) {