add Ready to Listen feature: audio book shelf on home + /listen browse page
- getBooksWithAudioCount() in pocketbase.ts aggregates done audio_jobs, deduplicates by chapter per slug, caches 5 min - GET /api/audio/books endpoint - home page: readyToListen shelf with headphones badge, chapter count, Listen button, hideable - /listen page: full grid with search, sort (most narrated / A-Z / recent), empty state
This commit is contained in:
17
ui/src/routes/api/audio/books/+server.ts
Normal file
17
ui/src/routes/api/audio/books/+server.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { getBooksWithAudioCount } from '$lib/server/pocketbase';
|
||||
|
||||
/**
|
||||
* GET /api/audio/books
|
||||
* Returns books that have at least one completed narrated chapter,
|
||||
* sorted by number of narrated chapters descending.
|
||||
* Cached 5 minutes at the CDN/proxy level.
|
||||
*/
|
||||
export const GET: RequestHandler = async () => {
|
||||
const entries = await getBooksWithAudioCount(100).catch(() => []);
|
||||
return json(
|
||||
{ books: entries },
|
||||
{ headers: { 'Cache-Control': 'public, max-age=300' } }
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user