92 lines
1.8 KiB
Markdown
92 lines
1.8 KiB
Markdown
# Daily Digest Blog (blog-backup)
|
|
|
|
Next.js app for an article-level daily digest. The core model is:
|
|
|
|
- One database row per article (`blog_articles`)
|
|
- Multiple articles can share the same `digest_date`
|
|
- RSS emits one `<item>` per article
|
|
|
|
## Local run
|
|
|
|
```bash
|
|
npm install
|
|
npm run dev
|
|
```
|
|
|
|
Dev server: `http://localhost:3002`
|
|
|
|
## Required env vars
|
|
|
|
Set in `.env.local`:
|
|
|
|
- `NEXT_PUBLIC_SUPABASE_URL`
|
|
- `NEXT_PUBLIC_SUPABASE_ANON_KEY`
|
|
- `SUPABASE_SERVICE_ROLE_KEY`
|
|
- `CRON_API_KEY`
|
|
|
|
## Database setup
|
|
|
|
Run migrations in `supabase/migrations` (or apply `schema.sql` for a fresh setup).
|
|
|
|
Main table migration:
|
|
|
|
- `supabase/migrations/20260303_create_blog_articles.sql`
|
|
|
|
## API surface
|
|
|
|
### Primary article API
|
|
|
|
- `GET /api/articles` (public)
|
|
- `POST /api/articles` (auth required)
|
|
- `GET /api/articles/:id` (public)
|
|
- `PATCH /api/articles/:id` (auth required)
|
|
- `DELETE /api/articles/:id` (auth required)
|
|
|
|
Auth for write routes:
|
|
|
|
- Supabase bearer token, or
|
|
- `x-api-key: <CRON_API_KEY>`
|
|
|
|
### Digest ingestion API
|
|
|
|
- `POST /api/digest` (requires `x-api-key`)
|
|
- Accepts `date` + `articles[]`, inserts one `blog_articles` row per article
|
|
|
|
### RSS
|
|
|
|
- `GET /api/rss` - article feed (one item per article)
|
|
- `GET /api/podcast/rss` - podcast feed for rows with `audio_url`
|
|
|
|
### Legacy compatibility
|
|
|
|
- `GET/POST/DELETE /api/messages` is kept as a compatibility shim over `blog_articles`.
|
|
|
|
## UI pages
|
|
|
|
- `/` public article feed
|
|
- `/podcast` audio episode list from article rows with audio
|
|
- `/admin` authenticated article CRUD + audio upload
|
|
- `/login` Supabase auth
|
|
|
|
## CLI
|
|
|
|
Use project CLI:
|
|
|
|
```bash
|
|
./scripts/blog.sh --help
|
|
```
|
|
|
|
Recommended commands:
|
|
|
|
- `article-add`
|
|
- `article-list`
|
|
- `article-delete`
|
|
- `rss`
|
|
|
|
## Audio
|
|
|
|
Audio files are stored in Supabase Storage bucket `podcast-audio` and linked via:
|
|
|
|
- `blog_articles.audio_url`
|
|
- `blog_articles.audio_duration`
|