Blog Page Component
The Blog page (pages/Blog.tsx) displays a grid of blog posts fetched from a WordPress CMS with fallback to static data.
Purpose
The Blog listing page:- Displays all available blog posts in a card grid layout
- Fetches dynamic content from WordPress CMS
- Provides fallback to static data if WordPress is unavailable
- Links to individual blog post detail pages
- Shows loading states during data fetch
Data Sources
WordPress CMS (Primary)
Blog posts are fetched from WordPress REST API:pages/Blog.tsx:14-21
WordPress API Details
lib/wordpress.ts:69-80
Static Fallback Data
If WordPress fetch fails, falls back to:BlogPost Data Structure
types.ts:8-17
Page Structure
Hero Section
Simple centered title and description:pages/Blog.tsx:32-37
Loading State
Skeleton cards displayed while fetching:pages/Blog.tsx:39-52
Features:
- Pulse animation
- Skeleton layout matches actual card
- Shows 3 placeholder cards
Blog Posts Grid
Responsive grid of blog post cards:pages/Blog.tsx:54-80
Components Used
GlassCard
hoverEffect={true}- Enable hover animationsclassName- Removes default padding, enables flexbox
SEO Component
State Management
- Initial state: Static posts, loading = true
- useEffect triggers: Fetch WordPress posts
- On success: Update posts, set loading = false
- On error: Keep static posts, set loading = false
Data Fetching Flow
1
Component Mounts
Initial render with static fallback posts and loading state = true
2
useEffect Executes
Calls
fetchBlogPosts() from WordPress API3
API Response
- Success: Update posts state with WordPress data
- Error: Keep fallback data, log warning to console
4
Finally Block
Set loading = false, triggering re-render with actual content
WordPress Data Mapping
WordPress posts are transformed to match the BlogPost interface:lib/wordpress.ts:33-51
Transformations:
- HTML stripping for title and excerpt
- Date formatting to Spanish locale
- Featured image extraction from embedded data
- Category extraction from taxonomy
Routing
Blog Listing
Individual Post
/blog/nuevas-tendencias-empaques-2024
Responsive Grid Layout
- Mobile (< 768px)
- Tablet (768px - 1024px)
- Desktop (> 1024px)
Card Hover Effects
Text Truncation
Excerpts are limited to 3 lines:Error Handling
Styling Patterns
Category Badge
Gradient Overlays
No gradient overlays used in blog listing (simple, clean design).Glassmorphism
Code Example
Performance Considerations
- Posts fetched once on component mount
- Loading state prevents layout shift
- Images loaded lazily by browser
- Fallback data ensures instant initial render
Related Pages
- Home Page - Shows 3 most recent posts
- Blog Detail Page - Individual post view (linked from cards)
- WordPress CMS - Content management system