47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
|
|
// app/sitemap/route.ts
|
||
|
|
|
||
|
|
interface SitemapPage {
|
||
|
|
loc: string;
|
||
|
|
lastmod: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const GET = async () => {
|
||
|
|
const BASE_URL = "https://trees.falktron.com";
|
||
|
|
|
||
|
|
const useCases = [
|
||
|
|
"forestry",
|
||
|
|
"research",
|
||
|
|
"agriculture",
|
||
|
|
"cities-communities",
|
||
|
|
];
|
||
|
|
|
||
|
|
const pages: SitemapPage[] = [
|
||
|
|
{ loc: `${BASE_URL}/`, lastmod: new Date().toISOString().split("T")[0] },
|
||
|
|
...useCases.map((slug) => ({
|
||
|
|
loc: `${BASE_URL}/use-cases/${slug}`,
|
||
|
|
lastmod: new Date().toISOString().split("T")[0],
|
||
|
|
})),
|
||
|
|
];
|
||
|
|
|
||
|
|
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
||
|
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||
|
|
${pages
|
||
|
|
.map(
|
||
|
|
(page) => `
|
||
|
|
<url>
|
||
|
|
<loc>${page.loc}</loc>
|
||
|
|
<lastmod>${page.lastmod}</lastmod>
|
||
|
|
</url>`
|
||
|
|
)
|
||
|
|
.join("")}
|
||
|
|
</urlset>`;
|
||
|
|
|
||
|
|
return new Response(xml, {
|
||
|
|
status: 200,
|
||
|
|
headers: {
|
||
|
|
"Content-Type": "application/xml",
|
||
|
|
"Cache-Control": "public, s-maxage=86400, stale-while-revalidate=3600",
|
||
|
|
},
|
||
|
|
});
|
||
|
|
};
|