2024-08-24 06:28:25 +02:00
|
|
|
import { getAllBlogPostSlugs } from "@/lib/getBlogPost";
|
2024-09-07 22:06:58 +02:00
|
|
|
import clientPromise from "@/lib/db";
|
2024-08-24 06:28:25 +02:00
|
|
|
|
2024-07-28 17:20:53 +02:00
|
|
|
export default async function sitemap() {
|
2024-09-07 09:12:48 +02:00
|
|
|
const blogPostSlugs = await getAllBlogPostSlugs();
|
2024-08-24 06:28:25 +02:00
|
|
|
|
2024-09-07 09:12:48 +02:00
|
|
|
const baseRoutes = [
|
|
|
|
"/",
|
|
|
|
"/blog",
|
2024-09-07 12:00:05 +02:00
|
|
|
"/changelog",
|
2024-09-07 09:12:48 +02:00
|
|
|
"/contact",
|
|
|
|
"/contribute",
|
|
|
|
"/downloads",
|
|
|
|
"/mods",
|
2024-09-07 12:00:05 +02:00
|
|
|
"/privacy",
|
2024-09-07 09:12:48 +02:00
|
|
|
"/tos",
|
|
|
|
"/vulnerabilities",
|
2024-09-13 06:39:59 +02:00
|
|
|
"/newsletter",
|
2024-09-13 16:17:37 +02:00
|
|
|
"/docs",
|
|
|
|
"/docs/mod-notes",
|
|
|
|
"/docs/requirements",
|
2024-09-13 06:39:59 +02:00
|
|
|
"/docs/mods/mod-files",
|
|
|
|
"/docs/mods/introduction",
|
|
|
|
"/docs/mods/mod-loading-order",
|
|
|
|
"/docs/mods/mod-development",
|
|
|
|
"/docs/mods/mod-development-legacy",
|
|
|
|
"/docs/server-side-javascript/svrjs-ssjs",
|
|
|
|
"/docs/server-side-javascript/migration",
|
|
|
|
"/docs/api/svrjs-api-legacy",
|
|
|
|
"/docs/api/svrjs-api",
|
|
|
|
"/docs/config/cgi-scgi-jsgi-php",
|
|
|
|
"/docs/config/cli-options",
|
|
|
|
"/docs/config/reverse-proxy-config",
|
|
|
|
"/docs/config/configuration",
|
|
|
|
"/docs/config/redirects",
|
|
|
|
"/docs/config/forward-proxy-notes",
|
|
|
|
"/docs/config/fastcgi-php-fpm",
|
|
|
|
"/docs/config/user-management",
|
|
|
|
"/docs/config/environment",
|
|
|
|
"/docs/config/virtual-hosts",
|
|
|
|
"/docs/config/http-auth",
|
|
|
|
"/docs/config/page-customization",
|
|
|
|
"/docs/config/client-secure",
|
|
|
|
"/docs/config/custom-error",
|
|
|
|
"/docs/getting-started/svrjs-commands",
|
|
|
|
"/docs/getting-started/updating-svrjs",
|
|
|
|
"/docs/getting-started/svrjs-utilities",
|
|
|
|
"/docs/getting-started/features",
|
|
|
|
"/docs/getting-started/svrjs-files",
|
|
|
|
"/docs/getting-started/installation"
|
2024-09-07 09:12:48 +02:00
|
|
|
].map((route) => ({
|
2024-09-08 13:16:43 +02:00
|
|
|
url: `${process.env.NEXT_PUBLIC_WEBSITE_URL}${route}`,
|
2024-09-07 09:12:48 +02:00
|
|
|
lastModified: new Date().toISOString().split("T")[0]
|
|
|
|
}));
|
2024-08-24 06:28:25 +02:00
|
|
|
|
2024-09-07 09:12:48 +02:00
|
|
|
const blogRoutes = blogPostSlugs.map((slug) => ({
|
2024-09-08 13:16:43 +02:00
|
|
|
url: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/blog/${slug.slug}`,
|
2024-09-07 09:12:48 +02:00
|
|
|
lastModified: new Date().toISOString().split("T")[0]
|
|
|
|
}));
|
2024-07-28 17:20:53 +02:00
|
|
|
|
2024-09-07 22:08:35 +02:00
|
|
|
let changelogRoutes: any[] = [];
|
2024-09-07 22:06:58 +02:00
|
|
|
try {
|
|
|
|
const client = await clientPromise;
|
|
|
|
const db = client.db(process.env.MONGODB_DB);
|
|
|
|
const slugs = await db.collection("pages").find().toArray();
|
|
|
|
changelogRoutes = slugs.map((slug) => ({
|
2024-09-08 13:16:43 +02:00
|
|
|
url: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/changelog/${slug.slug}`,
|
2024-09-07 22:06:58 +02:00
|
|
|
lastModified: new Date().toISOString().split("T")[0]
|
|
|
|
}));
|
|
|
|
} catch (err) {}
|
|
|
|
|
|
|
|
return [...baseRoutes, ...blogRoutes, ...changelogRoutes];
|
2024-07-28 17:20:53 +02:00
|
|
|
}
|