www/app/sitemap.ts
Xe Iaso 9447a4bef7
add blog component
Signed-off-by: Xe Iaso <me@xeiaso.net>
2024-09-20 13:41:03 -04:00

37 lines
903 B
TypeScript

import { allPosts } from "@/.content-collections/generated";
import { MetadataRoute } from "next";
export function getBaseUrl() {
return process.env.NODE_ENV === "production"
? "https://techaro.lol"
: "http://localhost:3000";
}
const basePath = getBaseUrl();
const generatedDate = new Date();
export default function sitemap(): MetadataRoute.Sitemap {
const staticPages = [
"/",
"/about",
"/blog",
"/contact",
"/services",
];
//@ts-ignore
return [
...staticPages.map((path) => ({
url: basePath + path,
lastModified: generatedDate,
changeFrequency: "daily",
priority: 1,
})),
...allPosts.map(({ date, urlPath, imageURL }) => ({
url: `${basePath}/${urlPath}`,
lastModified: new Date(date),
changeFrequency: "monthly",
priority: 0.8,
images: imageURL !== undefined ? [imageURL] : [],
}))
];
};