2026-04-12 10:11:23 +02:00
|
|
|
import FacilitySearch from "@/app/FacilitySearch";
|
|
|
|
|
import { API_URL } from "@/config/constants";
|
2026-04-12 22:07:51 +02:00
|
|
|
import {
|
|
|
|
|
createBreadcrumbJsonLd,
|
|
|
|
|
createCollectionPageJsonLd,
|
2026-04-18 09:00:16 +02:00
|
|
|
createItemListJsonLd,
|
2026-04-12 22:07:51 +02:00
|
|
|
createPageMetadata,
|
|
|
|
|
} from "@/app/seo";
|
2026-04-12 10:11:23 +02:00
|
|
|
|
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
|
|
2026-04-18 09:00:16 +02:00
|
|
|
const pageTitle = "Golfbaner i Norge";
|
2026-04-12 22:07:51 +02:00
|
|
|
const pageDescription =
|
2026-04-18 09:00:16 +02:00
|
|
|
"Finn golfbaner i Norge og filtrer på område, banestatus, antall hull og fasiliteter i TeeOffs samlede oversikt.";
|
2026-04-12 22:07:51 +02:00
|
|
|
|
|
|
|
|
export const metadata = createPageMetadata({
|
|
|
|
|
title: pageTitle,
|
|
|
|
|
description: pageDescription,
|
|
|
|
|
path: "/golfbaner",
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-12 10:11:23 +02:00
|
|
|
export default async function GolfCoursesIndexPage() {
|
|
|
|
|
let facilities = [];
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const res = await fetch(`${API_URL}/facilities`, {
|
|
|
|
|
next: { revalidate: 0 },
|
|
|
|
|
cache: "no-store",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!res.ok) {
|
|
|
|
|
throw new Error(`API returnerte status ${res.status}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
facilities = await res.json();
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Kritisk feil ved henting av golfbaner:", error);
|
|
|
|
|
facilities = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const safeData = Array.isArray(facilities) ? facilities : [];
|
2026-04-12 22:07:51 +02:00
|
|
|
const collectionJsonLd = createCollectionPageJsonLd({
|
|
|
|
|
name: pageTitle,
|
|
|
|
|
description: pageDescription,
|
|
|
|
|
path: "/golfbaner",
|
|
|
|
|
});
|
2026-04-18 09:00:16 +02:00
|
|
|
const itemListJsonLd = createItemListJsonLd({
|
|
|
|
|
name: pageTitle,
|
|
|
|
|
path: "/golfbaner",
|
|
|
|
|
items: safeData
|
|
|
|
|
.filter((facility) => facility?.slug && facility?.name)
|
|
|
|
|
.map((facility) => ({
|
|
|
|
|
name: facility.name,
|
|
|
|
|
path: `/golfbaner/${facility.slug}`,
|
|
|
|
|
description: facility.description,
|
|
|
|
|
})),
|
|
|
|
|
});
|
2026-04-12 22:07:51 +02:00
|
|
|
const breadcrumbJsonLd = createBreadcrumbJsonLd([
|
|
|
|
|
{ name: "Hjem", path: "/" },
|
|
|
|
|
{ name: "Golfbaner", path: "/golfbaner" },
|
|
|
|
|
]);
|
2026-04-12 10:11:23 +02:00
|
|
|
|
|
|
|
|
return (
|
2026-04-12 22:07:51 +02:00
|
|
|
<>
|
|
|
|
|
<script
|
|
|
|
|
type="application/ld+json"
|
|
|
|
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(collectionJsonLd) }}
|
|
|
|
|
/>
|
2026-04-18 09:00:16 +02:00
|
|
|
<script
|
|
|
|
|
type="application/ld+json"
|
|
|
|
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(itemListJsonLd) }}
|
|
|
|
|
/>
|
2026-04-12 22:07:51 +02:00
|
|
|
<script
|
|
|
|
|
type="application/ld+json"
|
|
|
|
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(breadcrumbJsonLd) }}
|
2026-04-12 10:11:23 +02:00
|
|
|
/>
|
2026-04-12 22:07:51 +02:00
|
|
|
<main className="site-shell min-h-screen">
|
|
|
|
|
<FacilitySearch
|
|
|
|
|
initialFacilities={safeData}
|
|
|
|
|
variant="catalog"
|
|
|
|
|
eyebrow="Golfbaner"
|
2026-04-18 09:00:16 +02:00
|
|
|
title="Golfbaner i Norge"
|
|
|
|
|
intro="Filtrer norske golfbaner etter område, banestatus, antall hull og fasiliteter, og gå videre til hver baneprofil."
|
2026-04-12 22:07:51 +02:00
|
|
|
/>
|
|
|
|
|
</main>
|
|
|
|
|
</>
|
2026-04-12 10:11:23 +02:00
|
|
|
);
|
|
|
|
|
}
|