51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import type { RequestHandler } from './$types';
|
|
import { locationPages } from '$lib/content/locations';
|
|
|
|
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' },
|
|
...locationPages.map((loc) => ({
|
|
path: `/locations/${loc.slug}`,
|
|
priority: '0.8',
|
|
changefreq: 'monthly'
|
|
})),
|
|
{ path: '/terms-and-conditions', priority: '0.3', changefreq: 'yearly' },
|
|
{ path: '/privacy-policy', priority: '0.3', changefreq: 'yearly' }
|
|
];
|
|
|
|
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>
|
|
<loc>${siteUrl}${path}</loc>
|
|
<lastmod>${lastmod}</lastmod>
|
|
<changefreq>${changefreq}</changefreq>
|
|
<priority>${priority}</priority>
|
|
</url>`
|
|
)
|
|
.join('\n')}
|
|
</urlset>`;
|
|
|
|
return new Response(body, {
|
|
headers: {
|
|
'Content-Type': 'application/xml; charset=utf-8'
|
|
}
|
|
});
|
|
};
|