43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { getAllPosts } from "@marketing/blog/utils/lib/posts";
|
|
import { config } from "@repo/config";
|
|
import { getBaseUrl } from "@repo/utils";
|
|
import { allLegalPages } from "content-collections";
|
|
import type { MetadataRoute } from "next";
|
|
import { docsSource } from "./docs-source";
|
|
|
|
const baseUrl = getBaseUrl();
|
|
const locales = config.i18n.enabled
|
|
? Object.keys(config.i18n.locales)
|
|
: [config.i18n.defaultLocale];
|
|
|
|
const staticMarketingPages = ["", "/changelog"];
|
|
|
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|
const posts = await getAllPosts();
|
|
|
|
return [
|
|
...staticMarketingPages.flatMap((page) =>
|
|
locales.map((locale) => ({
|
|
url: new URL(`/${locale}${page}`, baseUrl).href,
|
|
lastModified: new Date(),
|
|
})),
|
|
),
|
|
...posts.map((post) => ({
|
|
url: new URL(`/${post.locale}/blog/${post.path}`, baseUrl).href,
|
|
lastModified: new Date(),
|
|
})),
|
|
...allLegalPages.map((page) => ({
|
|
url: new URL(`/${page.locale}/legal/${page.path}`, baseUrl).href,
|
|
lastModified: new Date(),
|
|
})),
|
|
...docsSource.getLanguages().flatMap((locale) =>
|
|
docsSource.getPages(locale.language).map((page) => ({
|
|
url: new URL(
|
|
`/${locale.language}/docs/${page.slugs.join("/")}`,
|
|
baseUrl,
|
|
).href,
|
|
lastModified: new Date(),
|
|
})),
|
|
),
|
|
];
|
|
}
|