Skip to content

refactor: extract duplicated patterns into shared Card and Layout components#2

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1781894633-refactor-shared-utilities
Open

refactor: extract duplicated patterns into shared Card and Layout components#2
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1781894633-refactor-shared-utilities

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

The 4 card blocks in pages/index.tsx were identical in structure — only href, title text, and description differed. The page also inlined the full <Head> / <main> / <footer> wrapper, which any new page would need to duplicate.

What changed:

  • components/Card.tsx — typed CardProps { href, title, description } component replacing the repeated <a className={styles.card}>…</a> blocks.
  • components/Layout.tsx — typed LayoutProps { title?, description?, children } component encapsulating <Head>, <main>, and the Vercel footer. Defaults mirror the original hard-coded values.
  • pages/index.tsx — card data moved to a cards array, rendered via cards.map(c => <Card key={c.href} {...c} />). Page wrapper replaced with <Layout>…</Layout>.

Net effect: index.tsx drops from 72 to 51 lines; adding a new card or new page requires no copy-paste of boilerplate.

Link to Devin session: https://app.devin.ai/sessions/dfa5372eed5e4dfe8bef318387f898b9
Requested by: @Bautisa46

- Create components/Card.tsx: reusable card with href, title, description props
- Create components/Layout.tsx: reusable page wrapper with Head meta and footer
- Refactor pages/index.tsx to use data-driven card rendering via map
- Eliminates 4x repeated card markup pattern in index.tsx

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant