Add pages: standalone rich-text pages at top-level slugs (#64) #69

Merged
miko merged 1 commit from feature/64-pages into development 2026-11-04 10:40:24 +01:00
Owner

Closes #64

Summary

A Page is a standalone page of rich text outside the category tree, served at /<slug> (ADR-0015). Only admins manage pages.

 src/
 ├── app/
+│   ├── [slug]/page.tsx          # a page at its slug; app routes win
 │   └── admin/
+│       └── pages/               # list, new (title + slug → draft), [id] (edit, delete)
+├── contentPages/                # src/pages is Next's Pages Router dir
+│   ├── slug.ts                  # RESERVED_PAGE_SLUGS, pageSlugProblem, newPageSlug
+│   ├── actions.ts               # createPage, savePage, deletePage (requireAdmin)
+│   └── components/              # NewPageForm, PageForm, DeletePageForm
 ├── richText/
-│   └── document.ts              # parseRichText(json)
+│   └── document.ts              # parseRichText(json, blocks); PAGE_BLOCKS = {tables}
 └── search/
-    └── searchGuides.ts
+    └── search.ts                # guides + pages, merged by score
canViewPage(actor, page)
  draft      → admins only
  published  → public: everyone · internal: signed-in users
  • Table block (@editorjs/table): only in the page editor, with a switchable heading row and inline-only cells. Other documents drop tables when parsed. Tables scroll sideways on narrow screens.
  • Titlebar: "Pages" sits next to Settings for now, until the admin menu from #66 exists.
  • Schema: new Page model (unique slug, full-text searchText); migration 20261104100000_add_page.

Evidence

  • Before: no pages. /impressum → not found.
  • After:
    • vitest: 315 passed. New tests cover reserved slugs vs. src/app, canViewPage, the table round trip, rendering, and dropping tables outside pages, and mergeByScore.
    • playwright: 22 passed. e2e/pages.spec.ts checks:
      • an admin creates a page with a table, publishes it, makes it internal, then deletes it; guests and viewers see it only as its status and visibility allow
      • authors, viewers and guests can't reach /admin/pages
      • a derived slug works, while reserved and taken slugs are refused
      • search shows a page only to those allowed to see it
      • the table block isn't offered in guide descriptions

Merge Danger

Door: two-way

The migration only adds a table; rolling back means dropping Page.

Blast Radius: routing

  • /[slug] catches every unknown top-level path, so unknown URLs now hit the database once before showing not-found.
  • Search results now mix guides and pages; the summary reads "results" instead of "guides".

🤖 Generated with Claude Code

Closes #64 ## Summary A **Page** is a standalone page of rich text outside the category tree, served at `/<slug>` (ADR-0015). Only admins manage pages. ```diff src/ ├── app/ +│ ├── [slug]/page.tsx # a page at its slug; app routes win │ └── admin/ +│ └── pages/ # list, new (title + slug → draft), [id] (edit, delete) +├── contentPages/ # src/pages is Next's Pages Router dir +│ ├── slug.ts # RESERVED_PAGE_SLUGS, pageSlugProblem, newPageSlug +│ ├── actions.ts # createPage, savePage, deletePage (requireAdmin) +│ └── components/ # NewPageForm, PageForm, DeletePageForm ├── richText/ -│ └── document.ts # parseRichText(json) +│ └── document.ts # parseRichText(json, blocks); PAGE_BLOCKS = {tables} └── search/ - └── searchGuides.ts + └── search.ts # guides + pages, merged by score ``` ```text canViewPage(actor, page) draft → admins only published → public: everyone · internal: signed-in users ``` - **Table block** (`@editorjs/table`): only in the page editor, with a switchable heading row and inline-only cells. Other documents drop tables when parsed. Tables scroll sideways on narrow screens. - **Titlebar:** "Pages" sits next to Settings for now, until the admin menu from #66 exists. - **Schema:** new `Page` model (unique `slug`, full-text `searchText`); migration `20261104100000_add_page`. ## Evidence - **Before:** no pages. `/impressum` → not found. - **After:** - `vitest`: 315 passed. New tests cover reserved slugs vs. `src/app`, `canViewPage`, the table round trip, rendering, and dropping tables outside pages, and `mergeByScore`. - `playwright`: 22 passed. `e2e/pages.spec.ts` checks: - an admin creates a page with a table, publishes it, makes it internal, then deletes it; guests and viewers see it only as its status and visibility allow - authors, viewers and guests can't reach `/admin/pages` - a derived slug works, while reserved and taken slugs are refused - search shows a page only to those allowed to see it - the table block isn't offered in guide descriptions ## Merge Danger **Door:** two-way The migration only adds a table; rolling back means dropping `Page`. **Blast Radius:** routing - `/[slug]` catches every unknown top-level path, so unknown URLs now hit the database once before showing not-found. - Search results now mix guides and pages; the summary reads "results" instead of "guides". 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Admins create, edit, publish and delete pages under /admin/pages. A page
lives outside the category tree at /<slug>; reserved slugs (the app's own
top-level routes and a few set aside) are refused, and a test keeps the
list in step with src/app. Its visibility applies as set, a draft is seen
only by admins. The page editor adds a table block, allowed only in page
content, and search finds pages for those who may see them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miko merged commit 404b1beb83 into development 2026-11-04 10:40:24 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MassiveDynamic/kataba!69
No description provided.