Implement property directory search

This commit is contained in:
2026-05-26 11:59:22 +00:00
parent ab2f9677fa
commit bb80906d19
8 changed files with 621 additions and 86 deletions

View File

@@ -2,8 +2,7 @@ import type { Metadata } from 'next';
import Link from 'next/link';
import { notFound } from 'next/navigation';
import { Section } from '@/components/Section';
import { getPublishedPropertyBySlug } from '@/lib/properties';
import { propertySeedData } from '@/lib/propertySeedData';
import { buildFallbackProperty, getPublishedPropertyBySlug } from '@/lib/properties';
import { site } from '@/lib/site';
export const dynamic = 'force-dynamic';
@@ -49,63 +48,6 @@ function fallbackMetadata(slug: string) {
};
}
function buildFallbackProperty(slug: string) {
const seeded = propertySeedData.find((property) => property.slug === slug);
if (!seeded) return null;
return {
id: seeded.slug,
slug: seeded.slug,
title: seeded.title,
summary: seeded.summary,
longDescription: seeded.longDescription,
locationText: seeded.locationText,
sleeps: seeded.sleeps,
bedrooms: seeded.bedrooms,
bathrooms: seeded.bathrooms,
petsAllowed: seeded.petsAllowed,
published: true,
featured: seeded.featured,
minStayNights: seeded.minStayNights,
checkInTime: seeded.checkInTime,
checkOutTime: seeded.checkOutTime,
images: seeded.images.map((image, index) => ({
id: `${seeded.slug}-image-${index}`,
url: image.url,
altText: image.altText,
primaryImage: image.primaryImage ?? index === 0,
})),
amenities: seeded.amenities.map((amenity, index) => ({
amenityId: `${seeded.slug}-amenity-${index}`,
amenity: {
name: amenity,
},
})),
pricingRules: seeded.pricingRules.map((rule, index) => ({
id: `${seeded.slug}-pricing-${index}`,
label: rule.label || null,
basePriceCents: rule.basePriceCents,
weekendPriceCents: rule.weekendPriceCents ?? null,
guestDeltaCents: rule.guestDeltaCents ?? null,
validFrom: rule.validFrom ? new Date(`${rule.validFrom}T00:00:00.000Z`) : null,
validTo: rule.validTo ? new Date(`${rule.validTo}T00:00:00.000Z`) : null,
})),
availability: seeded.availabilityBlocks.map((block, index) => ({
id: `${seeded.slug}-availability-${index}`,
startDate: new Date(`${block.startDate}T00:00:00.000Z`),
endDate: new Date(`${block.endDate}T00:00:00.000Z`),
reason: block.reason,
notes: block.notes ?? null,
})),
testimonials: seeded.testimonials.map((testimonial, index) => ({
id: `${seeded.slug}-testimonial-${index}`,
authorName: testimonial.authorName,
content: testimonial.content,
rating: testimonial.rating ?? null,
})),
};
}
export async function generateMetadata({ params }: PropertyPageProps): Promise<Metadata> {
const { slug } = await params;