Get all projects and update sitemaps for it immediatly as well
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { getAllProjects } from "@/content/projects/projects";
|
||||
import { getSettings } from "@/content/settings/settings";
|
||||
import { getProjectRoute } from "@/lib/routing";
|
||||
import type { APIRoute } from "astro";
|
||||
import minifyXML from "minify-xml";
|
||||
|
||||
@@ -14,12 +16,20 @@ export const GET = (async ({ params }) => {
|
||||
|
||||
const currentPage = params.page;
|
||||
|
||||
let pages: SitemapPage[] = [
|
||||
{
|
||||
url: "/",
|
||||
lastModified: new Date()
|
||||
}
|
||||
];
|
||||
const projects = await getAllProjects(settings);
|
||||
const selectedProjects = projects.slice(
|
||||
((Number(currentPage) - 1) * settings.sitemap.perPage),
|
||||
Number(currentPage) * settings.sitemap.perPage - 1
|
||||
);
|
||||
|
||||
let pages: SitemapPage[] = [];
|
||||
|
||||
selectedProjects.forEach((project) => {
|
||||
pages.push({
|
||||
url: getProjectRoute(settings.project, project),
|
||||
lastModified: project.lastModified
|
||||
});
|
||||
});
|
||||
|
||||
let sitemapContent = `
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
@@ -44,8 +54,9 @@ export const GET = (async ({ params }) => {
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const settings = await getSettings();
|
||||
const projects = await getAllProjects(settings);
|
||||
|
||||
const projectCount = 250;
|
||||
const projectCount = projects.length;
|
||||
const perPage = settings.sitemap.perPage;
|
||||
const pages = Math.ceil(projectCount / perPage);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user