Rocky_Mountain_Vending/scripts/one-off/modify_parts_page.py

77 lines
4.1 KiB
Python

import re
# Read the original parts file
with open('app/services/parts/page.tsx', 'r') as f:
content = f.read()
# Add ArrowRight import if missing
if 'ArrowRight' not in content:
content = content.replace('import Link from \'next/link\';', 'import Link from \'next/link\';\nimport { ArrowRight } from \'lucide-react\';')
# Create Related Services section similar to repairs page
related_services = '''
{/* Related Services Section */}
<section className="py-20 md:py-28 bg-background">
<div className="container mx-auto px-4 max-w-6xl">
<div className="text-center mb-12 md:mb-16">
<h2 className="text-3xl font-bold tracking-tight md:text-4xl lg:text-5xl mb-4 text-balance">Our Complete Service Network</h2>
<p className="text-lg text-muted-foreground max-w-2xl mx-auto text-pretty leading-relaxed mb-8">
Rocky Mountain Vending provides comprehensive vending solutions across Utah
</p>
</div>
<div className="grid gap-8 md:grid-cols-3">
<Card className="border-border/50 hover:border-secondary/50 transition-colors">
<CardContent className="pt-8 text-center">
<Wrench className="h-12 w-12 text-primary mx-auto mb-4" />
<h3 className="text-xl font-semibold mb-3">Vending Machine Parts</h3>
<p className="text-muted-foreground mb-6">
Quality replacement parts and components for all major vending machine brands
</p>
<Link href="/services/parts" className="inline-flex items-center gap-2 text-primary hover:underline font-medium">
View Parts Services <ArrowRight className="h-4 w-4" />
</Link>
</CardContent>
</Card>
<Card className="border-border/50 hover:border-secondary/50 transition-colors">
<CardContent className="pt-8 text-center">
<MapPin className="h-12 w-12 text-primary mx-auto mb-4" />
<h3 className="text-xl font-semibold mb-3">Service Areas</h3>
<p className="text-muted-foreground mb-6">
Serving 20+ cities across Utah with free delivery and installation
</p>
<Link href="/service-areas" className="inline-flex items-center gap-2 text-primary hover:underline font-medium">
View Service Areas <ArrowRight className="h-4 w-4" />
</Link>
</CardContent>
</Card>
<Card className="border-border/50 hover:border-secondary/50 transition-colors">
<CardContent className="pt-8 text-center">
<Clock className="h-12 w-12 text-primary mx-auto mb-4" />
<h3 className="text-xl font-semibold mb-3">Moving Services</h3>
<p className="text-muted-foreground mb-6">
Professional vending machine relocation and installation services
</p>
<Link href="/services/moving" className="inline-flex items-center gap-2 text-primary hover:underline font-medium">
View Moving Services <ArrowRight className="h-4 w-4" />
</Link>
</CardContent>
</Card>
</div>
</div>
</section>
'''
# Insert before a typical section - looking for Services section or similar
services_pattern = r'<section.*?className="py-20.*?bg-muted.*?">'
if re.search(services_pattern, content):
content = re.sub(services_pattern, related_services + '\n\n <section className="py-20 md:py-28 bg-muted/30">', content, flags=re.DOTALL)
else:
# Fallback: add before any py-20 section
py20_pattern = r'<section.*?className="py-20.*">'
if re.search(py20_pattern, content):
content = re.sub(py20_pattern, related_services + '\n\n <section className="py-20 md:py-28 bg-background">', content, flags=re.DOTALL)
# Write the modified content
with open('app/services/parts/page.tsx', 'w') as f:
f.write(content)
print("✅ Successfully added internal links to Parts page!")