import { notFound } from "next/navigation"; import type { Metadata } from "next"; import { getLocationBySlug, getAllLocationSlugs } from "@/lib/location-data"; import { businessConfig, socialProfiles } from "@/lib/seo-config"; import { Phone, Mail, Globe, Clock, CreditCard, MapPin } from "lucide-react"; import { Card, CardContent } from "@/components/ui/card"; import { ReviewsSection } from "@/components/reviews-section"; import { Button } from "@/components/ui/button"; import Link from "next/link"; interface LocationPageProps { params: Promise<{ location: string }>; } // Known non-location routes that should be handled by the catch-all route const NON_LOCATION_ROUTES = ['machines-we-use', 'machines-for-sale']; // Generate static params for all locations export async function generateStaticParams() { const slugs = getAllLocationSlugs(); return slugs.map((slug) => ({ location: slug, })); } // Generate metadata for each location page export async function generateMetadata({ params }: LocationPageProps): Promise { const { location } = await params; // If this is a known non-location route, return notFound to let catch-all handle it if (NON_LOCATION_ROUTES.includes(location)) { return { title: "Page Not Found | Rocky Mountain Vending", }; } const locationData = getLocationBySlug(location); if (!locationData) { return { title: "Location Not Found | Rocky Mountain Vending", }; } const title = `Vending Machine Supplier in ${locationData.city}, ${locationData.stateAbbr} | Rocky Mountain Vending`; const description = `Get FREE vending machines for your ${locationData.city} business! Rocky Mountain Vending provides quality vending machine sales, repairs, and service in ${locationData.city}, ${locationData.state}. Call (435) 233-9668.`; return { title, description, keywords: [ `vending machines ${locationData.city}`, `vending machine supplier ${locationData.city}`, `free vending machines ${locationData.city}`, `vending machine repair ${locationData.city}`, `${locationData.city} vending`, ...locationData.neighborhoods.map((n) => `vending machines ${n}`), ], openGraph: { title, description, url: `${businessConfig.website}/vending-machines-${location}`, type: "website", locale: "en_US", siteName: businessConfig.name, }, twitter: { card: "summary_large_image", title, description, }, alternates: { canonical: `${businessConfig.website}/vending-machines-${location}`, }, }; } export default async function LocationPage({ params }: LocationPageProps) { const { location } = await params; // If this is a known non-location route, return notFound to let catch-all handle it if (NON_LOCATION_ROUTES.includes(location)) { notFound(); } const locationData = getLocationBySlug(location); if (!locationData) { notFound(); } // Generate structured data for the location const structuredData = { "@context": "https://schema.org", "@type": "LocalBusiness", name: businessConfig.name, description: `Rocky Mountain Vending provides high-quality vending machines, vending machine sales, and vending machine repair services to businesses and schools across ${locationData.city}, ${locationData.state}.`, url: `${businessConfig.website}/vending-machines-${location}`, telephone: businessConfig.phoneFormatted, priceRange: "$$", foundingDate: businessConfig.openingDate, areaServed: { "@type": "City", name: locationData.city, address: { "@type": "PostalAddress", addressLocality: locationData.city, addressRegion: locationData.stateAbbr, postalCode: locationData.zipCode, addressCountry: "US", }, }, geo: { "@type": "GeoCoordinates", latitude: locationData.latitude, longitude: locationData.longitude, }, openingHoursSpecification: [ { "@type": "OpeningHoursSpecification", dayOfWeek: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"], opens: "08:00", closes: "17:00", }, ], paymentAccepted: "Credit Card, Debit Card, American Express, Discover, MasterCard, Visa", availableLanguage: ["English"], sameAs: [ socialProfiles.linkedin, socialProfiles.facebook, socialProfiles.youtube, socialProfiles.twitter, locationData.chamberUrl, locationData.cityWebsite, ...locationData.localLinks.map((link) => link.url), ], }; return ( <>