mirror of
https://github.com/BradNut/personal-website-sveltekit
synced 2025-09-08 23:20:18 +00:00
Allowing robots on personal site and creating sitemap from pages.
This commit is contained in:
parent
bf9a0be0ff
commit
72dd691732
2 changed files with 57 additions and 1 deletions
57
src/routes/sitemap.xml/+server.ts
Normal file
57
src/routes/sitemap.xml/+server.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
import { PUBLIC_SITE_URL } from '$env/static/public';
|
||||||
|
|
||||||
|
const site = `https://${PUBLIC_SITE_URL}`;
|
||||||
|
|
||||||
|
export const GET: RequestHandler = async function GET({ setHeaders }) {
|
||||||
|
const xml = `<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<urlset
|
||||||
|
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
|
||||||
|
xmlns:news="https://www.google.com/schemas/sitemap-news/0.9"
|
||||||
|
xmlns:xhtml="https://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:mobile="https://www.google.com/schemas/sitemap-mobile/1.0"
|
||||||
|
xmlns:image="https://www.google.com/schemas/sitemap-image/1.1"
|
||||||
|
xmlns:video="https://www.google.com/schemas/sitemap-video/1.1"
|
||||||
|
>
|
||||||
|
<url>
|
||||||
|
<loc>${site}</loc>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1</priority>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>${site}/about</loc>
|
||||||
|
<changefreq>monthly</changefreq>
|
||||||
|
<priority>0.4</priority>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>${site}/articles</loc>
|
||||||
|
<changefreq>weekly</changefreq>
|
||||||
|
<priority>1</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>${site}/portfolio</loc>
|
||||||
|
<changefreq>monthly</changefreq>
|
||||||
|
<priority>0.4</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>${site}/privacy</loc>
|
||||||
|
<changefreq>monthly</changefreq>
|
||||||
|
<priority>0.1</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>${site}/uses</loc>
|
||||||
|
<changefreq>monthly</changefreq>
|
||||||
|
<priority>0.4</priority>
|
||||||
|
</url>
|
||||||
|
</urlset>
|
||||||
|
`;
|
||||||
|
|
||||||
|
setHeaders({
|
||||||
|
'cache-control': 'max-age=0, s-maxage=3600',
|
||||||
|
'Content-Type': 'application/xml'
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Response(xml);
|
||||||
|
};
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
User-agent: *
|
User-agent: *
|
||||||
Disallow:
|
|
||||||
Loading…
Reference in a new issue