Files
ai-taxonomy-literature-anal…/pages/api/blocks/[id].ts
T
claude-bot 5407bf4dff
Deploy / deploy (push) Successful in 8m0s
Page blocks: papers and content pages as flat lists of story blocks in the database
A page is now an ordered list of independent blocks (analysis.page_block), no sections and no
headings; every block has an id shown on the page so it can be pointed at. Paper detail pages
use page "paper/<conf>/<ext_id>", analysis pages on /contents use "content/<node id>".

- /api/blocks (list, replace a page, add) and /api/blocks/:id (get, patch, move, delete)
- dynamic block types (stats, tool-table, paper-table, benchmark-table) are filled from the
  database at render time; the two content pages are rendered from their blocks (seeded with
  defaults on first view)
- one-time migration copies the legacy articles into blocks (section titles dropped, links
  become a links block); legacy tables are kept untouched
- old /api/articles, ArticleView and PaperGroup removed

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FbMbJPadPzVwvt9rU9GBNo
2026-10-23 22:51:54 +08:00

21 lines
897 B
TypeScript

import { route, bodyObject, HttpError } from '../../../lib/api';
import { deleteBlock, getBlock, patchBlock } from '../../../lib/block-store';
export const config = { api: { bodyParser: { sizeLimit: '8mb' } } };
const id = (req: { query: Record<string, string | string[] | undefined> }) => {
const n = Number(req.query.id);
if (!Number.isInteger(n) || n < 1) throw new HttpError(400, 'block id must be a positive integer');
return n;
};
// GET /api/blocks/:id one block
// PATCH /api/blocks/:id {"data": {...}} replaces the data; {"set": {"key": value|null}} changes some keys; {"type": ...} changes the type;
// {"after": id} or {"before": id} moves it within its page
// DELETE /api/blocks/:id
export default route({
GET: (req) => getBlock(id(req)),
PATCH: (req) => patchBlock(id(req), bodyObject(req)),
DELETE: (req) => deleteBlock(id(req)),
});