Page Detail Component
ThePageDetail component is a catch-all route handler that fetches and renders WordPress pages by their slug. It enables content editors to create custom pages in WordPress CMS without requiring code changes.
Location
File:pages/PageDetail.tsxRoute:
/:slug (catch-all)
Purpose
This component allows non-technical users to:- Create new pages in WordPress admin
- Publish content without deploying code
- Maintain consistent branding and layout
- Add custom landing pages, legal pages, or campaign pages
Route Configuration
Defined inApp.tsx:39 as the last route (catch-all):
App.tsx
Data Flow
1
Extract slug from URL
Uses React Router’s Example: URL
useParams to get the page slug:https://example.com/privacy-policy → slug = "privacy-policy"2
Fetch WordPress page
Calls
fetchWPPageBySlug to retrieve page data:3
Render page content
Displays the fetched page with title, featured image, and HTML content.
Component Structure
Hero Section
pages/PageDetail.tsx
Content Section
Renders WordPress HTML using Tailwind Typography:pages/PageDetail.tsx
State Management
Loading State
pages/PageDetail.tsx
Error/404 State
pages/PageDetail.tsx
SEO Configuration
pages/PageDetail.tsx
WordPress API Integration
UsesfetchWPPageBySlug from lib/wordpress.ts:82-94:
lib/wordpress.ts
Creating Pages in WordPress
1
Log into WordPress admin
Access your WordPress dashboard at
https://your-cms.com/wp-admin2
Create a new page
Go to Pages → Add New and create your content with the WordPress editor.
3
Set the page slug
In the page settings, set a URL-friendly slug (e.g.,
privacy-policy).4
Add featured image (optional)
Set a featured image for the hero section background.
5
Publish
Click Publish. The page is immediately accessible at
https://your-site.com/{slug}Use Cases
Legal Pages
/privacy-policy- Privacy policy/terms-of-service- Terms and conditions/cookie-policy- Cookie usage policy
Marketing Pages
/promo-2024- Seasonal campaigns/partner-program- Partnership information/case-studies- Customer success stories
Support Pages
/shipping-info- Shipping and delivery details/returns- Return policy/faq-extended- Extended FAQ content
Navigation Integration
Add WordPress pages to footer or navigation:components/Footer.tsx
Related Components
- Blog Detail - Blog post renderer
- SEO Component - Meta tags
- GlassCard - Content wrapper
Related Types
- WPPage - WordPress page data structure
Error Handling
The component handles:- Network errors - WordPress API unreachable
- 404 errors - Page slug doesn’t exist
- Missing slug - No slug parameter in URL
- CORS errors - WordPress CORS not configured
Best Practices
Cache considerations: WordPress REST API responses can be cached. If content doesn’t update immediately, clear cache or check WordPress caching plugins.