Blog Detail Page
TheBlogDetail page component renders a full blog post article with metadata, featured image, and formatted content. It fetches posts from WordPress CMS by slug or falls back to static data.
Location
File:pages/BlogDetail.tsxRoute:
/blog/:slug
Features
- Dynamic routing with slug parameter from URL
- WordPress integration via
fetchBlogPoststo find post by slug - Static fallback using
siteContent.blog.postswhen WordPress unavailable - SEO optimization with dynamic meta tags
- Loading state while fetching WordPress data
- 404 handling for non-existent slugs
- Responsive layout with featured image, metadata, and content
Route Configuration
Defined inApp.tsx:36:
App.tsx
https://example.com/blog/que-es-la-mioglobina
Data Flow
1
Extract slug from URL
Uses
useParams hook from React Router to get the slug parameter:2
Fetch WordPress posts
Attempts to fetch all posts from WordPress:
3
Find post by slug
Searches the posts array for a matching slug:
4
Render post or 404
Displays the post if found, otherwise shows “not found” message.
Component Structure
Hero Section
Displays category badge, title, metadata, and featured image:pages/BlogDetail.tsx
Content Section
Renders HTML content from WordPress usingdangerouslySetInnerHTML:
pages/BlogDetail.tsx
Loading State
pages/BlogDetail.tsx
404 State
pages/BlogDetail.tsx
SEO Integration
Dynamic SEO tags based on post data:pages/BlogDetail.tsx
Styling
The blog content uses Tailwind Typography plugin classes:prose- Base typography stylesprose-invert- Light text on dark backgroundprose-lg- Larger font sizes for readabilitymax-w-none- Remove default max-width constraint
index.html:35:
index.html
WordPress vs Static Data
The component gracefully handles both data sources:Usage Example
Navigation from Blog listing page:pages/Blog.tsx
Related Components
- Blog Page - Blog listing page
- SEO Component - Meta tags management
- GlassCard - Card wrapper
Related Types
- BlogPost - Blog post data structure
Back Navigation
The page includes a back link to the blog listing:pages/BlogDetail.tsx