import { notFound } from 'next/navigation'; import { loadImageMapping } from '@/lib/wordpress-content'; import { generateSEOMetadata, generateStructuredData } from '@/lib/seo'; import { getPageBySlug } from '@/lib/wordpress-data-loader'; import { cleanWordPressContent } from '@/lib/clean-wordpress-content'; import { VendingMachinesShowcase } from '@/components/vending-machines-showcase'; import Image from 'next/image'; import type { Metadata } from 'next'; // This route maps to the main vending-machines WordPress page const WORDPRESS_SLUG = 'vending-machines'; export async function generateMetadata(): Promise { const page = getPageBySlug(WORDPRESS_SLUG); if (!page) { return { title: 'Page Not Found | Rocky Mountain Vending', }; } return generateSEOMetadata({ title: page.title || 'Machines We Use', description: page.seoDescription || page.excerpt || '', excerpt: page.excerpt, date: page.date, modified: page.modified, image: page.images?.[0]?.localPath, }); } export default async function MachinesWeUsePage() { try { const page = getPageBySlug(WORDPRESS_SLUG); if (!page) { notFound(); } // Load image mapping (optional, won't break if it fails) let imageMapping: any = {}; try { imageMapping = loadImageMapping(); } catch (e) { // Silently fail - image mapping is optional if (process.env.NODE_ENV === 'development') { console.warn('Could not load image mapping:', e); } imageMapping = {}; } // Clean and render WordPress content as styled React components const content = page.content ? ( cleanWordPressContent(String(page.content), { imageMapping, pageTitle: page.title // Pass page title to avoid duplicate headings }) ) : (

No content available.

); // Generate structured data let structuredData; try { structuredData = generateStructuredData({ title: page.title || 'Machines We Use', description: page.seoDescription || page.excerpt || '', url: page.link || page.urlPath || `https://rockymountainvending.com/vending-machines/machines-we-use/`, datePublished: page.date, dateModified: page.modified || page.date, type: 'WebPage', }); } catch (e) { // Silently use fallback structured data in production if (process.env.NODE_ENV === 'development') { console.error('Error generating structured data:', e); } structuredData = { '@context': 'https://schema.org', '@type': 'WebPage', headline: page.title || 'Machines We Use', description: page.seoDescription || '', url: `https://rockymountainvending.com/vending-machines/machines-we-use/`, }; } return ( <>