feat(admin): rebuild admin area around the Article domain

The admin area was managing a Hacker News-style Item model that the
public site never consumed, so the homepage always fell back to sample
data. Rebuild the admin area around the real public content model.

Backend:
- Remove the Item model, schema and admin API
- Admin API now manages articles at /api/v1/admin/articles (CRUD) with
  /api/v1/admin/authors and /api/v1/admin/categories reference data
- Add public read-only article endpoints (/api/v1/articles,
  /api/v1/articles/{id}): no auth, published-only, newest-first
- Rewrite Article schemas; ArticleRead embeds author and category
- Add idempotent seed_content.py dev seeder (3 authors, 4 categories,
  6 published articles)

Frontend:
- Admin UI rewritten around articles: AdminDashboard list, new
  EditArticlePage (create/edit, author/category selects, published
  toggle, Lexical editor, debounced auto-save)
- Replace AdminItem types and api client with the article domain
- Update App routes, AdminLayout sidebar, DeleteConfirmation, Lexical
  editor labels and Home/client comments to article terminology

Tests:
- Rewrite admin unit tests and the Playwright admin e2e spec for the
  article domain; add test_articles.py for the public endpoints and
  seeder
This commit is contained in:
Daniel Samson committed 2026-10-31 18:31:05 +00:00
1 parent de96d0b152
commit afa399776f
29 files changed
+2465 -1658

No files matched your search

+29 -20
View File
@@ -1,54 +1,63 @@
/**
* Admin area types (mirror the backend `schemas.item` payloads).
* Admin area types (mirror the backend `schemas.article` payloads).
*
* The backend returns snake_case JSON; these interfaces keep the wire
* shape 1:1 (no remapping) because they are only consumed by the admin
* pages.
* pages. The related `author` and `category` are always embedded by the
* backend (`ArticleRead`), so they are required here.
*/
import type { Author, Category } from './index';
/** One news item as managed in the admin area. */
export interface AdminItem {
/** One article as managed in the admin area. */
export interface AdminArticle {
id: number;
title: string;
url: string;
points: number;
/** Username the item belongs to (denormalized). */
username: string;
/** HTML body produced by the Lexical editor. */
content: string;
author_id: number;
category_id: number;
/** Embedded author (always present on the wire). */
author: Author;
/** Embedded category (always present on the wire). */
category: Category;
/** Whether the article is visible on the public site. */
published: boolean;
/** ISO-8601 timestamp. */
created_at: string;
}
/** Payload of `GET /api/v1/admin/items` (paginated list). */
export interface AdminItemsPage {
items: AdminItem[];
/** Payload of `GET /api/v1/admin/articles` (paginated list). */
export interface AdminArticlesPage {
articles: AdminArticle[];
total: number;
page: number;
page_size: number;
total_pages: number;
}
/** Sortable columns of the item list. */
export type AdminSortBy = 'title' | 'created_at' | 'points';
/** Sortable columns of the article list. */
export type AdminSortBy = 'title' | 'created_at';
export type AdminSortOrder = 'asc' | 'desc';
/** Query parameters of the item list endpoint. */
/** Query parameters of the article list endpoint. */
export interface AdminListParams {
page: number;
pageSize: number;
/** Case-insensitive match on title OR url. */
/** Case-insensitive match on title OR content. */
search: string;
sortBy: AdminSortBy;
sortOrder: AdminSortOrder;
}
/** Payload of `POST /api/v1/admin/items` and `PUT /api/v1/admin/items/{id}`. */
export interface AdminItemInput {
/**
* Payload of `POST /api/v1/admin/articles` and
* `PUT /api/v1/admin/articles/{id}`.
*/
export interface AdminArticleInput {
title: string;
url: string;
points: number;
username: string;
content: string;
author_id: number;
category_id: number;
published: boolean;
}