Files
gw-svelte/src/routes/sitemap.xml/+server.ts
T

45 lines
1.4 KiB
TypeScript
Raw Normal View History

2026-05-02 08:26:18 +12:00
import type { RequestHandler } from './$types';
const siteUrl = 'https://www.goodwalk.co.nz';
interface SitemapRoute {
path: string;
priority: string;
changefreq: string;
}
const routes: SitemapRoute[] = [
{ path: '/', priority: '1.0', changefreq: 'weekly' },
{ path: '/pack-walks', priority: '0.9', changefreq: 'monthly' },
{ path: '/dog-walking', priority: '0.9', changefreq: 'monthly' },
{ path: '/puppy-visits', priority: '0.9', changefreq: 'monthly' },
{ path: '/our-pricing', priority: '0.8', changefreq: 'monthly' },
{ path: '/about', priority: '0.7', changefreq: 'monthly' },
{ path: '/contact-us', priority: '0.7', changefreq: 'monthly' },
{ path: '/terms-and-conditions', priority: '0.3', changefreq: 'yearly' },
{ path: '/privacy-policy', priority: '0.3', changefreq: 'yearly' }
2026-05-02 08:26:18 +12:00
];
export const GET: RequestHandler = () => {
const lastmod = new Date().toISOString().split('T')[0];
const body = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${routes
.map(
({ path, priority, changefreq }) => ` <url>
2026-05-02 08:26:18 +12:00
<loc>${siteUrl}${path}</loc>
<lastmod>${lastmod}</lastmod>
<changefreq>${changefreq}</changefreq>
<priority>${priority}</priority>
2026-05-02 08:26:18 +12:00
</url>`
)
.join('\n')}
</urlset>`;
return new Response(body, {
headers: {
'Content-Type': 'application/xml; charset=utf-8'
}
});
};