Skip to content

Move getPosts call out of ui/sections/blog-post-list into the page entry point #60

Description

@ooloth

Why

A presentational section component that fetches live Notion data conflates data-fetching with rendering, prevents isolated testing without network access, and duplicates fetch logic that already belongs at the page level.

Current state

ui/sections/blog-post-list.tsx imports getPosts from @/io/notion/getPosts (line 3) and calls (await getPosts({ … })).unwrap() (line 30) inside the component. A section component is performing a live Notion API call that belongs at the page entry point (app/blog/page.tsx).

Ideal state

  • PostList (or the blog-post-list section component) accepts an already-fetched PostListItem[] prop and contains no imports from @/io.
  • app/blog/page.tsx calls getPosts and passes the result as a prop to the section component.
  • The section is renderable in tests with plain props and no network access.

Starting points

  • ui/sections/blog-post-list.tsx — line 3 (import) and line 30 (call) to remove; component signature to update
  • app/blog/page.tsx — the correct location for the getPosts call
  • io/notion/getPosts.ts — the fetch function

QA plan

  1. Open ui/sections/blog-post-list.tsx — expect no imports from @/io and a posts: PostListItem[] prop in the component signature.
  2. Open app/blog/page.tsx — expect getPosts called here and the result passed to the section component.
  3. Run npm run build and npm run test:ci — expect no regressions.

Done when

ui/sections/blog-post-list.tsx contains no @/io imports, accepts a posts prop, and the blog page continues to render correctly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions