Skip to content

Commit 958ed6c

Browse files
committed
♻️ Enable to get url slug or workbook id in sitemap.xml (#2020)
1 parent 15fffa6 commit 958ed6c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import type { RequestHandler } from '@sveltejs/kit';
1111
import * as sitemap from 'super-sitemap';
1212

1313
import * as workBooksCrud from '$lib/services/workbooks';
14+
15+
import { getUrlSlugFrom } from '$lib/utils/workbooks';
1416
import { INTERNAL_SERVER_ERROR } from '$lib/constants/http-response-status-codes';
1517

1618
/**
@@ -40,7 +42,10 @@ export const GET: RequestHandler = async () => {
4042
const workbooks = await workBooksCrud.getWorkBooks();
4143
publishedWorkBookIds = workbooks
4244
.filter((workbook) => workbook.isPublished)
43-
.map((workbook) => String(workbook.id));
45+
.map((workbook) => {
46+
// Note: To get the urlSlug, passing an empty string for authorName is sufficient
47+
return getUrlSlugFrom({ ...workbook, authorName: '' });
48+
});
4449
} catch (e) {
4550
const errorMessage = e instanceof Error ? e.message : 'Unknown error';
4651
console.error(`Failed to generate sitemap: ${errorMessage}`);

0 commit comments

Comments
 (0)