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

38 lines
874 B
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';
const routes = [
'/',
'/pack-walks',
'/dog-walking',
'/puppy-visits',
'/our-pricing',
'/about',
'/booking',
'/terms-and-conditions',
'/privacy-policy'
];
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) => ` <url>
<loc>${siteUrl}${path}</loc>
<lastmod>${lastmod}</lastmod>
<changefreq>${path === '/' ? 'weekly' : 'monthly'}</changefreq>
<priority>${path === '/' ? '1.0' : '0.8'}</priority>
</url>`
)
.join('\n')}
</urlset>`;
return new Response(body, {
headers: {
'Content-Type': 'application/xml; charset=utf-8'
}
});
};