Create more sitemaps for the categories
This commit is contained in:
52
astro/src/pages/sitemap/albums-[page].xml.ts
Normal file
52
astro/src/pages/sitemap/albums-[page].xml.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { getSettings } from "@/content/settings/settings";
|
||||
import type { APIRoute } from "astro";
|
||||
import minifyXML from "minify-xml";
|
||||
|
||||
export const GET = (async ({ params }) => {
|
||||
const settings = await getSettings();
|
||||
|
||||
const currentPage = params.page;
|
||||
|
||||
let pages: SitemapPage[] = [
|
||||
{
|
||||
url: "/",
|
||||
lastModified: new Date()
|
||||
}
|
||||
];
|
||||
|
||||
let sitemapContent = `
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
${pages.map((page) => `
|
||||
<sitemap>
|
||||
<loc>${settings.website.domainName}${page.url}</loc>
|
||||
<lastmod>${page.lastModified.toISOString()}</lastmod>
|
||||
</sitemap>
|
||||
`).join('')}
|
||||
</sitemapindex>
|
||||
`;
|
||||
|
||||
return new Response(minifyXML(sitemapContent), {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
headers: {
|
||||
"Content-Type": "application/xml"
|
||||
}
|
||||
});
|
||||
}) satisfies APIRoute;
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const settings = await getSettings();
|
||||
|
||||
const albumCount = 250;
|
||||
const perPage = settings.sitemap.perPage;
|
||||
const pages = Math.ceil(albumCount / perPage);
|
||||
|
||||
let items: any[] = [];
|
||||
|
||||
for (let i = 0; i < pages; i++) {
|
||||
items.push({ params: { page: (i + 1) } });
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
40
astro/src/pages/sitemap/albums.xml.ts
Normal file
40
astro/src/pages/sitemap/albums.xml.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { getSettings } from "@/content/settings/settings";
|
||||
import type { APIRoute } from "astro";
|
||||
import minifyXML from "minify-xml";
|
||||
|
||||
export const GET = (async () => {
|
||||
const settings = await getSettings();
|
||||
|
||||
const albumCount = 250;
|
||||
const perPage = settings.sitemap.perPage;
|
||||
const pages = Math.ceil(albumCount / perPage);
|
||||
|
||||
let sitemaps: SitemapIndex[] = [];
|
||||
|
||||
for (let i = 0; i < pages; i++) {
|
||||
sitemaps.push({
|
||||
url: `/sitemap/albums-${i + 1}.xml`,
|
||||
lastModified: new Date()
|
||||
});
|
||||
}
|
||||
|
||||
let sitemapContent = `
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
${sitemaps.map((item) => `
|
||||
<sitemap>
|
||||
<loc>${settings.website.domainName}${item.url}</loc>
|
||||
<lastmod>${item.lastModified.toISOString()}</lastmod>
|
||||
</sitemap>
|
||||
`).join('')}
|
||||
</sitemapindex>
|
||||
`;
|
||||
|
||||
return new Response(minifyXML(sitemapContent), {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
headers: {
|
||||
"Content-Type": "application/xml"
|
||||
}
|
||||
});
|
||||
}) satisfies APIRoute;
|
||||
@@ -25,8 +25,6 @@ export const GET = (async () => {
|
||||
});
|
||||
}
|
||||
|
||||
console.log(pages, sitemaps);
|
||||
|
||||
let sitemapContent = `
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
|
||||
52
astro/src/pages/sitemap/pages-[page].xml.ts
Normal file
52
astro/src/pages/sitemap/pages-[page].xml.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { getSettings } from "@/content/settings/settings";
|
||||
import type { APIRoute } from "astro";
|
||||
import minifyXML from "minify-xml";
|
||||
|
||||
export const GET = (async ({ params }) => {
|
||||
const settings = await getSettings();
|
||||
|
||||
const currentPage = params.page;
|
||||
|
||||
let pages: SitemapPage[] = [
|
||||
{
|
||||
url: "/",
|
||||
lastModified: new Date()
|
||||
}
|
||||
];
|
||||
|
||||
let sitemapContent = `
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
${pages.map((page) => `
|
||||
<sitemap>
|
||||
<loc>${settings.website.domainName}${page.url}</loc>
|
||||
<lastmod>${page.lastModified.toISOString()}</lastmod>
|
||||
</sitemap>
|
||||
`).join('')}
|
||||
</sitemapindex>
|
||||
`;
|
||||
|
||||
return new Response(minifyXML(sitemapContent), {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
headers: {
|
||||
"Content-Type": "application/xml"
|
||||
}
|
||||
});
|
||||
}) satisfies APIRoute;
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const settings = await getSettings();
|
||||
|
||||
const pageCount = 250;
|
||||
const perPage = settings.sitemap.perPage;
|
||||
const pages = Math.ceil(pageCount / perPage);
|
||||
|
||||
let items: any[] = [];
|
||||
|
||||
for (let i = 0; i < pages; i++) {
|
||||
items.push({ params: { page: (i + 1) } });
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
40
astro/src/pages/sitemap/pages.xml.ts
Normal file
40
astro/src/pages/sitemap/pages.xml.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { getSettings } from "@/content/settings/settings";
|
||||
import type { APIRoute } from "astro";
|
||||
import minifyXML from "minify-xml";
|
||||
|
||||
export const GET = (async () => {
|
||||
const settings = await getSettings();
|
||||
|
||||
const pageCount = 250;
|
||||
const perPage = settings.sitemap.perPage;
|
||||
const pages = Math.ceil(pageCount / perPage);
|
||||
|
||||
let sitemaps: SitemapIndex[] = [];
|
||||
|
||||
for (let i = 0; i < pages; i++) {
|
||||
sitemaps.push({
|
||||
url: `/sitemap/pages-${i + 1}.xml`,
|
||||
lastModified: new Date()
|
||||
});
|
||||
}
|
||||
|
||||
let sitemapContent = `
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
${sitemaps.map((item) => `
|
||||
<sitemap>
|
||||
<loc>${settings.website.domainName}${item.url}</loc>
|
||||
<lastmod>${item.lastModified.toISOString()}</lastmod>
|
||||
</sitemap>
|
||||
`).join('')}
|
||||
</sitemapindex>
|
||||
`;
|
||||
|
||||
return new Response(minifyXML(sitemapContent), {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
headers: {
|
||||
"Content-Type": "application/xml"
|
||||
}
|
||||
});
|
||||
}) satisfies APIRoute;
|
||||
59
astro/src/pages/sitemap/projects-[page].xml.ts
Normal file
59
astro/src/pages/sitemap/projects-[page].xml.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { getSettings } from "@/content/settings/settings";
|
||||
import type { APIRoute } from "astro";
|
||||
import minifyXML from "minify-xml";
|
||||
|
||||
export const GET = (async ({ params }) => {
|
||||
const settings = await getSettings();
|
||||
|
||||
if (!settings.project.enabled) {
|
||||
return new Response(null, {
|
||||
status: 204,
|
||||
statusText: "Not Found"
|
||||
});
|
||||
}
|
||||
|
||||
const currentPage = params.page;
|
||||
|
||||
let pages: SitemapPage[] = [
|
||||
{
|
||||
url: "/",
|
||||
lastModified: new Date()
|
||||
}
|
||||
];
|
||||
|
||||
let sitemapContent = `
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
${pages.map((page) => `
|
||||
<sitemap>
|
||||
<loc>${settings.website.domainName}${page.url}</loc>
|
||||
<lastmod>${page.lastModified.toISOString()}</lastmod>
|
||||
</sitemap>
|
||||
`).join('')}
|
||||
</sitemapindex>
|
||||
`;
|
||||
|
||||
return new Response(minifyXML(sitemapContent), {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
headers: {
|
||||
"Content-Type": "application/xml"
|
||||
}
|
||||
});
|
||||
}) satisfies APIRoute;
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const settings = await getSettings();
|
||||
|
||||
const projectCount = 250;
|
||||
const perPage = settings.sitemap.perPage;
|
||||
const pages = Math.ceil(projectCount / perPage);
|
||||
|
||||
let items: any[] = [];
|
||||
|
||||
for (let i = 0; i < pages; i++) {
|
||||
items.push({ params: { page: (i + 1) } });
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
47
astro/src/pages/sitemap/projects.xml.ts
Normal file
47
astro/src/pages/sitemap/projects.xml.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { getSettings } from "@/content/settings/settings";
|
||||
import type { APIRoute } from "astro";
|
||||
import minifyXML from "minify-xml";
|
||||
|
||||
export const GET = (async () => {
|
||||
const settings = await getSettings();
|
||||
|
||||
if (!settings.blog.enabled) {
|
||||
return new Response(null, {
|
||||
status: 204,
|
||||
statusText: "Not Found"
|
||||
});
|
||||
}
|
||||
|
||||
const projectCount = 250;
|
||||
const perPage = settings.sitemap.perPage;
|
||||
const pages = Math.ceil(projectCount / perPage);
|
||||
|
||||
let sitemaps: SitemapIndex[] = [];
|
||||
|
||||
for (let i = 0; i < pages; i++) {
|
||||
sitemaps.push({
|
||||
url: `/sitemap/projects-${i + 1}.xml`,
|
||||
lastModified: new Date()
|
||||
});
|
||||
}
|
||||
|
||||
let sitemapContent = `
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
${sitemaps.map((item) => `
|
||||
<sitemap>
|
||||
<loc>${settings.website.domainName}${item.url}</loc>
|
||||
<lastmod>${item.lastModified.toISOString()}</lastmod>
|
||||
</sitemap>
|
||||
`).join('')}
|
||||
</sitemapindex>
|
||||
`;
|
||||
|
||||
return new Response(minifyXML(sitemapContent), {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
headers: {
|
||||
"Content-Type": "application/xml"
|
||||
}
|
||||
});
|
||||
}) satisfies APIRoute;
|
||||
Reference in New Issue
Block a user