Skip to content

Commit 17a04b5

Browse files
Copilotmaiertech
andauthored
Add videos to sitemap (#1209)
* Initial plan * feat: add videos to sitemap Agent-Logs-Url: https://github.com/maiertech/website/sessions/21daa4a7-1f6b-4530-95e8-50295a6f791c Co-authored-by: maiertech <1482402+maiertech@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: maiertech <1482402+maiertech@users.noreply.github.com>
1 parent 266eaed commit 17a04b5

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/routes/sitemap.xml/+server.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ORIGIN } from '$env/static/private';
22
import { sorted as notes } from '$lib/server/collections/notes.js';
33
import { sorted as posts } from '$lib/server/collections/posts.js';
4+
import { sorted as videos } from '$lib/server/collections/videos.js';
45
import type { RequestHandler } from './$types';
56

67
export const prerender = true;
@@ -22,8 +23,16 @@ export const GET: RequestHandler = async () => {
2223
</url>`
2324
);
2425

26+
// Create sitemap entries for videos.
27+
const videoEntries = videos.map(
28+
(video) => `\t<url>
29+
<loc>${ORIGIN}${video.path}</loc>
30+
<lastmod>${video.publishedDate}</lastmod>
31+
</url>`
32+
);
33+
2534
// Add additional collections to this array.
26-
const pages = [...postEntries, ...noteEntries];
35+
const pages = [...postEntries, ...noteEntries, ...videoEntries];
2736

2837
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
2938
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

0 commit comments

Comments
 (0)