2026-04-12 22:07:51 +02:00
|
|
|
import type { MetadataRoute } from "next";
|
|
|
|
|
import { API_URL } from "@/config/constants";
|
|
|
|
|
import { getAvailablePlaceConfigs } from "@/app/facilityData";
|
2026-04-13 21:43:55 +02:00
|
|
|
import { getCourseVisits, getOpinionArticles } from "@/content/courseVisits";
|
2026-04-12 22:07:51 +02:00
|
|
|
import { buildAbsoluteUrl } from "@/app/seo";
|
|
|
|
|
|
|
|
|
|
type SitemapFacility = {
|
|
|
|
|
slug?: string;
|
|
|
|
|
status_updated_at?: string | null;
|
|
|
|
|
vtg_updated_at?: string | null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const staticRoutes: MetadataRoute.Sitemap = [
|
|
|
|
|
{
|
|
|
|
|
url: buildAbsoluteUrl("/"),
|
|
|
|
|
lastModified: new Date(),
|
|
|
|
|
changeFrequency: "daily",
|
|
|
|
|
priority: 1,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
url: buildAbsoluteUrl("/golfbaner"),
|
|
|
|
|
lastModified: new Date(),
|
|
|
|
|
changeFrequency: "daily",
|
|
|
|
|
priority: 0.95,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
url: buildAbsoluteUrl("/medlemskap"),
|
|
|
|
|
lastModified: new Date(),
|
|
|
|
|
changeFrequency: "daily",
|
|
|
|
|
priority: 0.8,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
url: buildAbsoluteUrl("/vtg"),
|
|
|
|
|
lastModified: new Date(),
|
|
|
|
|
changeFrequency: "daily",
|
|
|
|
|
priority: 0.8,
|
|
|
|
|
},
|
2026-04-13 13:51:11 +02:00
|
|
|
{
|
|
|
|
|
url: buildAbsoluteUrl("/banebesok"),
|
|
|
|
|
lastModified: new Date(),
|
|
|
|
|
changeFrequency: "weekly",
|
|
|
|
|
priority: 0.72,
|
|
|
|
|
},
|
2026-04-13 21:43:55 +02:00
|
|
|
{
|
|
|
|
|
url: buildAbsoluteUrl("/meninger"),
|
|
|
|
|
lastModified: new Date(),
|
|
|
|
|
changeFrequency: "weekly",
|
|
|
|
|
priority: 0.7,
|
|
|
|
|
},
|
2026-04-13 13:51:11 +02:00
|
|
|
{
|
|
|
|
|
url: buildAbsoluteUrl("/turneringer"),
|
|
|
|
|
lastModified: new Date(),
|
|
|
|
|
changeFrequency: "daily",
|
|
|
|
|
priority: 0.68,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
url: buildAbsoluteUrl("/klubbnummer"),
|
|
|
|
|
lastModified: new Date(),
|
|
|
|
|
changeFrequency: "weekly",
|
|
|
|
|
priority: 0.64,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
url: buildAbsoluteUrl("/om"),
|
|
|
|
|
lastModified: new Date(),
|
|
|
|
|
changeFrequency: "monthly",
|
|
|
|
|
priority: 0.45,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
url: buildAbsoluteUrl("/kontakt"),
|
|
|
|
|
lastModified: new Date(),
|
|
|
|
|
changeFrequency: "monthly",
|
|
|
|
|
priority: 0.42,
|
|
|
|
|
},
|
2026-04-12 22:07:51 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|
|
|
|
let facilities: SitemapFacility[] = [];
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const res = await fetch(`${API_URL}/facilities`, { cache: "no-store" });
|
|
|
|
|
if (res.ok) {
|
|
|
|
|
const data = await res.json();
|
|
|
|
|
facilities = Array.isArray(data) ? data : [];
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
facilities = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const placeRoutes = getAvailablePlaceConfigs().map((slug) => ({
|
|
|
|
|
url: buildAbsoluteUrl(`/sted/${slug}`),
|
|
|
|
|
lastModified: new Date(),
|
|
|
|
|
changeFrequency: "daily" as const,
|
|
|
|
|
priority: slug === "norge" ? 0.9 : 0.75,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const facilityRoutes = facilities
|
|
|
|
|
.filter((facility) => Boolean(facility.slug))
|
|
|
|
|
.map((facility) => ({
|
|
|
|
|
url: buildAbsoluteUrl(`/golfbaner/${facility.slug}`),
|
|
|
|
|
lastModified: facility.status_updated_at || facility.vtg_updated_at || new Date(),
|
|
|
|
|
changeFrequency: "daily" as const,
|
|
|
|
|
priority: 0.7,
|
|
|
|
|
}));
|
|
|
|
|
|
2026-04-13 21:43:55 +02:00
|
|
|
const courseVisitRoutes = (await getCourseVisits()).map((article) => ({
|
2026-04-13 15:29:43 +02:00
|
|
|
url: buildAbsoluteUrl(`/banebesok/${article.slug}`),
|
|
|
|
|
lastModified: article.updatedAt || article.publishedAt,
|
|
|
|
|
changeFrequency: "monthly" as const,
|
|
|
|
|
priority: 0.58,
|
|
|
|
|
}));
|
|
|
|
|
|
2026-04-13 21:43:55 +02:00
|
|
|
const opinionRoutes = (await getOpinionArticles()).map((article) => ({
|
|
|
|
|
url: buildAbsoluteUrl(`/meninger/${article.slug}`),
|
|
|
|
|
lastModified: article.updatedAt || article.publishedAt,
|
|
|
|
|
changeFrequency: "monthly" as const,
|
|
|
|
|
priority: 0.56,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
return [...staticRoutes, ...placeRoutes, ...facilityRoutes, ...courseVisitRoutes, ...opinionRoutes];
|
2026-04-12 22:07:51 +02:00
|
|
|
}
|