Refactor: split admin god-modules + dedup paginated feed rendering
#9 in tonybierman/dx-blog — merged 2026-05-29
Structural cleanup of the two largest concentrations of code, flagged in a codebase review. Pure refactoring — no behavior changes; component and server-fn bodies are unchanged.
1. Split admin god-modules into per-domain submodules
pages/admin.rs (1,296 lines) and server/admin.rs (655 lines) had each grown into a single hard-to-navigate file.
pages/admin.rs→pages/admin/{mod,posts,comments,media,users,settings,appearance,dashboard,taxonomy}.rsserver/admin.rs→server/admin/{mod,posts,comments,media,taxonomy}.rs
The public surface is preserved via re-exports — main.rs's use pages::admin::{…} and server::posts's crate::server::admin::can_edit_post resolve as before, and the editor's use crate::server::admin::* glob still finds every server fn. Shared helpers moved to their natural owner: can_edit_post stays in server/admin/mod.rs (used by the public post page too); the post-only validators moved into posts.rs; save_with_status into appearance.rs; AdminShell + ActionButton into pages/admin/mod.rs.
2. Dedup paginated feed rendering into a FeedSection component
The feed_states!(posts, feed => … FeedBody { … on_change: page.set }) block was copy-pasted across six feeds (home, category, tag, author, archive, search). Extracted into one FeedSection { posts, shape, page } widget that owns the load/error/skeleton states and wires the pager back to the caller's page signal; callers keep their own fetch closure (which reads page() to load the right slice).
SearchResults still renders its "{n} result(s)" line — now from a small separate read of the resource — then delegates the feed to FeedSection.
Net across both commits: +36 / −2,004 lines.
Verification
cargo check --no-default-features --features server,sqlite— cleancargo check --no-default-features --features web --target wasm32-unknown-unknown— clean (only the pre-existing#[cfg(server)]client-only warnings)cargo test --no-default-features --features server,sqlite— 11/11 pass
🤖 Generated with Claude Code
Last updated 2026-05-30
Links to this note
Merged pull requests, newest first.