37 lines
903 B
TypeScript
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] : [],
|
|
}))
|
|
];
|
|
}; |