52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { MetadataRoute } from "next";
|
|
import { getAllPosts } from "@/lib/blog";
|
|
|
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|
const baseUrl = "https://sztucznainteligencjadlafirm.pl";
|
|
|
|
// Static pages
|
|
const routes = [
|
|
{
|
|
url: `${baseUrl}/`,
|
|
lastModified: new Date(),
|
|
changeFrequency: "monthly" as const,
|
|
priority: 1.0,
|
|
},
|
|
{
|
|
url: `${baseUrl}/about/`,
|
|
lastModified: new Date(),
|
|
changeFrequency: "monthly" as const,
|
|
priority: 0.8,
|
|
},
|
|
{
|
|
url: `${baseUrl}/oferta/`,
|
|
lastModified: new Date(),
|
|
changeFrequency: "monthly" as const,
|
|
priority: 0.9,
|
|
},
|
|
{
|
|
url: `${baseUrl}/blog/`,
|
|
lastModified: new Date(),
|
|
changeFrequency: "weekly" as const,
|
|
priority: 0.9,
|
|
},
|
|
];
|
|
|
|
// Dynamic blog posts
|
|
try {
|
|
const posts = await getAllPosts();
|
|
const blogPosts = posts.map((post) => ({
|
|
url: `${baseUrl}/blog/${post.slug}/`,
|
|
lastModified: new Date(post.updatedAt),
|
|
changeFrequency: "weekly" as const,
|
|
priority: 0.7,
|
|
}));
|
|
|
|
return [...routes, ...blogPosts];
|
|
} catch (error) {
|
|
console.error("Error generating sitemap:", error);
|
|
// Return static routes if blog posts fail to load
|
|
return routes;
|
|
}
|
|
}
|