Initial commit

This commit is contained in:
ponzischeme89
2026-05-02 08:26:18 +12:00
commit b7ea05f150
119 changed files with 13641 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
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'
}
});
};
+22
View File
@@ -0,0 +1,22 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
import { GET } from './+server';
describe('sitemap endpoint', () => {
afterEach(() => {
vi.useRealTimers();
});
it('returns a sitemap covering the published routes', async () => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2026-05-01T09:15:00Z'));
const response = GET();
const body = await response.text();
expect(response.headers.get('content-type')).toBe('application/xml; charset=utf-8');
expect(body).toContain('<loc>https://www.goodwalk.co.nz/</loc>');
expect(body).toContain('<loc>https://www.goodwalk.co.nz/privacy-policy</loc>');
expect(body).toContain('<lastmod>2026-05-01</lastmod>');
expect(body.match(/<url>/g)).toHaveLength(9);
});
});