tech-debt: News module: post code in one place; the post page combines news and upcoming events
Back to our planType
tech-debt
Summary
Do for news posts what the events step does for events: one home, each rule written once, and the post page gets upcoming events from the events module instead of querying them itself.
Problem
Post code is spread over 7 folders (app/(frontend)/posts, the posts sitemap, collections/Posts, collections/Categories, components/Card, components/CollectionArchive, components/PostsFeed, components/SidebarPosts, heros/PostHero, blocks/RelatedPosts, blocks/ArchiveBlock, search/, utilities/formatAuthors.ts, the post half of utilities/feeds.ts).
posts/[slug]/page.tsxruns its own queries for the post, related posts, recent posts and upcoming events, so news code knows how events are stored.components/PostsFeedimports a page's server action fromapp/.- Several places cast Payload results (
as Post[],as CardPostData[]).
Proposed fix
Create src/modules/news/ with the same shape as events (see docs/architecture/README.md: domain/, use-cases/, data/, cms/, ui/, actions.ts, index.ts, server.ts, cms.ts). Move the Posts and Categories collections, the post UI, the archive and related-posts blocks, search, and author formatting. The post page in app/ combines the two: it calls @/modules/news/server for the post and @/modules/events/server for upcoming events, so the news module never imports events (rule 3). The archive block's listing moves here and site uses it through news's entry files.
Acceptance criteria
- Not done: No post logic remains outside
src/modules/newsexcept thin route files and block registration. - Not done: Data functions return module types; no casts on Payload results.
- Not done: Unit tests for the domain rules (e.g. author formatting, related-post selection).
- Not done:
/posts,/posts/<slug>,/posts/page/<n>, search, the posts sitemap, the home page news block and "Load more" behave as before. - Not done: Boundary lint reports no violations for the news module.
Depends on
#131 (events module). Step 7 of #127.
Area
frontend, cms
Priority
medium
Generated by Claude Code, opens in a new tab