53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import { notFound } from "next/navigation";
|
|
import Header from "@/components/Header";
|
|
import Footer from "@/components/Footer";
|
|
import BusinessDetailView from "@/components/BusinessDetail";
|
|
import {
|
|
getAllBusinessSlugs,
|
|
getBusinessBySlug,
|
|
} from "@/data/business";
|
|
import styles from "./page.module.css";
|
|
|
|
export function generateStaticParams() {
|
|
return getAllBusinessSlugs().map((slug) => ({ slug }));
|
|
}
|
|
|
|
export async function generateMetadata({
|
|
params,
|
|
}: {
|
|
params: Promise<{ slug: string }>;
|
|
}) {
|
|
const { slug } = await params;
|
|
const business = getBusinessBySlug(slug);
|
|
if (!business) {
|
|
return { title: "Business | IranBay" };
|
|
}
|
|
return {
|
|
title: `${business.name} | IranBay`,
|
|
description: business.description.slice(0, 140),
|
|
};
|
|
}
|
|
|
|
export default async function BusinessDetailPage({
|
|
params,
|
|
}: {
|
|
params: Promise<{ slug: string }>;
|
|
}) {
|
|
const { slug } = await params;
|
|
const business = getBusinessBySlug(slug);
|
|
|
|
if (!business) {
|
|
notFound();
|
|
}
|
|
|
|
return (
|
|
<div className={styles.page}>
|
|
<Header />
|
|
<main className={styles.shell}>
|
|
<BusinessDetailView business={business} />
|
|
</main>
|
|
<Footer />
|
|
</div>
|
|
);
|
|
}
|