71 lines
2.4 KiB
TypeScript
71 lines
2.4 KiB
TypeScript
// app/sitemap.ts
|
|
// Erreichbar unter: https://deinedomain.de/sitemap.xml
|
|
|
|
import type { MetadataRoute } from "next";
|
|
|
|
const BASE_URL = "https://deinedomain.de"; // ← Domain anpassen
|
|
|
|
// ─── Typen ───────────────────────────────────────────────────────────────────
|
|
// interface BlogPost {
|
|
// slug: string;
|
|
// updatedAt: Date;
|
|
// }
|
|
|
|
// ─── Daten laden (nur aktivieren wenn Blog vorhanden) ────────────────────────
|
|
// async function getBlogPosts(): Promise<BlogPost[]> {
|
|
// Hier API/CMS-Call, z.B.:
|
|
// const res = await fetch(`${BASE_URL}/api/posts`);
|
|
// return res.json();
|
|
// }
|
|
|
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|
// ─── Statische Seiten ──────────────────────────────────────────────────────
|
|
const staticPages: MetadataRoute.Sitemap = [
|
|
{
|
|
url: BASE_URL,
|
|
lastModified: new Date(),
|
|
changeFrequency: "monthly",
|
|
priority: 1.0,
|
|
},
|
|
{
|
|
url: `${BASE_URL}/about`,
|
|
lastModified: new Date(),
|
|
changeFrequency: "monthly",
|
|
priority: 0.8,
|
|
},
|
|
{
|
|
url: `${BASE_URL}/kontakt`,
|
|
lastModified: new Date(),
|
|
changeFrequency: "yearly",
|
|
priority: 0.6,
|
|
},
|
|
{
|
|
url: `${BASE_URL}/datenschutz`,
|
|
lastModified: new Date(),
|
|
changeFrequency: "yearly",
|
|
priority: 0.3,
|
|
},
|
|
{
|
|
url: `${BASE_URL}/impressum`,
|
|
lastModified: new Date(),
|
|
changeFrequency: "yearly",
|
|
priority: 0.3,
|
|
},
|
|
];
|
|
|
|
// ─── Dynamische Blog-Seiten (auskommentiert bis Blog vorhanden) ────────────
|
|
// const posts = await getBlogPosts();
|
|
// const blogPages: MetadataRoute.Sitemap = posts.map((post) => ({
|
|
// url: `${BASE_URL}/blog/${post.slug}`,
|
|
// lastModified: post.updatedAt,
|
|
// changeFrequency: "weekly",
|
|
// priority: 0.7,
|
|
// }));
|
|
|
|
// ─── Alles zusammenführen ──────────────────────────────────────────────────
|
|
return [
|
|
...staticPages,
|
|
// ...blogPages, ← aktivieren wenn Blog live ist
|
|
];
|
|
}
|