Skip to content

Header layout fetches Notion posts directly instead of receiving them as props #155

Description

@ooloth

Current state

ui/layout/header.tsx imports and calls getPosts from io/notion/getPosts at render time, performing a live Notion API call inside a layout component. Layout components are not the appropriate place for I/O; they should receive already-fetched data as props from a page or data-fetching boundary. The same violation exists in ui/sections/blog-post-list.tsx, which also calls getPosts directly. The layout layer carrying its own I/O means the Notion call cannot be controlled, cached, or tested independently of the component.

Ideal state

  • Header accepts posts as a prop; it contains no imports from @/io
  • BlogPostList (or equivalent section component) accepts posts as a prop; it contains no imports from @/io
  • Page-level components call getPosts once and pass the result to both Header and the post-listing section
  • Each component is renderable in tests with plain props and zero network access

Out of scope

Starting points

  • ui/layout/header.tsx — the getPosts import and call to remove; the props interface to add
  • ui/sections/blog-post-list.tsx — the same pattern in the section component
  • Page files that render Header and BlogPostList — the new home for the getPosts call

QA plan

  1. Open ui/layout/header.tsx — expect no imports from @/io and a posts prop in the component signature
  2. Open ui/sections/blog-post-list.tsx — expect no imports from @/io and a posts prop
  3. Run npm run build — expect no build errors
  4. Open the home page and a blog post page in the browser — expect the header nav and post list to render correctly with all expected posts

Done when

Neither ui/layout/header.tsx nor ui/sections/blog-post-list.tsx imports from @/io; both receive post data as props.

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