diff --git a/frontend/src/app/admin/layout.tsx b/frontend/src/app/admin/layout.tsx new file mode 100755 index 0000000..d6fcca9 --- /dev/null +++ b/frontend/src/app/admin/layout.tsx @@ -0,0 +1,16 @@ +import type { Metadata } from "next"; + +export const metadata: Metadata = { + robots: { + index: false, + follow: false, + googleBot: { + index: false, + follow: false, + }, + }, +}; + +export default function AdminLayout({ children }: { children: React.ReactNode }) { + return children; +} diff --git a/frontend/src/app/golfbaner/[slug]/page.tsx b/frontend/src/app/golfbaner/[slug]/page.tsx old mode 100644 new mode 100755 index fbae7a1..31475ac --- a/frontend/src/app/golfbaner/[slug]/page.tsx +++ b/frontend/src/app/golfbaner/[slug]/page.tsx @@ -1,17 +1,79 @@ -// page.tsx +import type { Metadata } from "next"; import { API_URL } from "@/config/constants"; +import { + createBreadcrumbJsonLd, + createFacilityJsonLd, + createPageMetadata, + trimDescription, +} from "@/app/seo"; import FacilityDetailView from "./FacilityDetailView"; -export default async function GolfCoursePage({ params }: { params: Promise<{ slug: string }> }) { +type GolfCoursePageProps = { + params: Promise<{ slug: string }>; +}; + +async function getFacility(slug: string) { + const res = await fetch(`${API_URL}/facilities/${slug}`, { cache: "no-store" }); + return res.json(); +} + +export async function generateMetadata({ params }: GolfCoursePageProps): Promise { const { slug } = await params; - - const res = await fetch(`${API_URL}/facilities/${slug}`, { cache: 'no-store' }); - const facility = await res.json(); + + try { + const facility = await getFacility(slug); + if (!facility || facility.error) { + return createPageMetadata({ + title: "Golfbane ikke funnet", + description: "Golfanlegget du prøvde å åpne finnes ikke på TeeOff.", + path: `/golfbaner/${slug}`, + }); + } + + const title = `${facility.name}${facility.city ? ` i ${facility.city}` : ""}`; + const fallbackDescription = `${facility.name} på TeeOff med banestatus, priser, kontaktinfo og lenker til nyttige ressurser.`; + + return createPageMetadata({ + title, + description: trimDescription(facility.description) || fallbackDescription, + path: `/golfbaner/${slug}`, + image: facility.image_url, + }); + } catch { + return createPageMetadata({ + title: "Golfbane", + description: "Golfanlegg på TeeOff med status, priser og klubbinfo.", + path: `/golfbaner/${slug}`, + }); + } +} + +export default async function GolfCoursePage({ params }: GolfCoursePageProps) { + const { slug } = await params; + const facility = await getFacility(slug); if (!facility || facility.error) { return
Fant ikke golfbanen...
; } - // Vi sender dataene til den navngitte komponenten - return ; + const facilityJsonLd = createFacilityJsonLd(facility); + const breadcrumbJsonLd = createBreadcrumbJsonLd([ + { name: "Hjem", path: "/" }, + { name: "Golfbaner", path: "/golfbaner" }, + { name: facility.name, path: `/golfbaner/${facility.slug}` }, + ]); + + return ( + <> +