MovieCard component renders a clickable card for a movie with its poster image, title, duration, and ratings from IMDb, Metacritic, and Rotten Tomatoes.
Props
Movie object containing the movie data. Must include:
id: Movie IDtitle: Movie titleposter_url: URL to the movie poster image (optional)duration_minutes: Movie duration in minutes (optional)rating: IMDb rating (optional)metacritic_rating: Metacritic score (optional)rotten_tomatoes_rating: Rotten Tomatoes percentage (optional)
Custom link URL for the card. If not provided, defaults to
/movies/{id}-{slugified-title}Features
- Responsive poster: Displays movie poster with 2:3 aspect ratio, or shows a 🎬 emoji placeholder if no poster is available
- Hover effects: Card scales up slightly on hover, title changes to accent color
- Multiple rating sources: Shows IMDb, Metacritic, and Rotten Tomatoes ratings with their respective icons
- Lazy loading: Poster images use lazy loading for better performance
- Automatic slugification: Generates SEO-friendly URLs from movie titles
Usage
Basic Example
Custom Link
Styling
The component uses Tailwind CSS classes and relies on the following CSS variables from your theme:bg-secondary: Card background colortext-accent: Hover text colortext-gray-400: Secondary text colortext-gray-500: Placeholder text color
Type Definition
TheMovie type is defined in src/lib/queries.ts: