Skip to content

Commit 954d72d

Browse files
committed
♻️ Use union type and update JSDoc (#2020)
1 parent 958ed6c commit 954d72d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/lib/utils/workbooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Roles } from '$lib/types/user';
2-
import { type WorkbookList } from '$lib/types/workbook';
2+
import type { WorkBook, WorkbookList } from '$lib/types/workbook';
33

44
import { isAdmin } from '$lib/utils/authorship';
55

@@ -14,7 +14,7 @@ export function canViewWorkBook(role: Roles, isPublished: boolean) {
1414
* @param workbook - The workbook object containing urlSlug and id properties
1515
* @returns The URL slug if available, otherwise the workbook ID as a string
1616
*/
17-
export function getUrlSlugFrom(workbook: WorkbookList): string {
17+
export function getUrlSlugFrom(workbook: WorkbookList | WorkBook): string {
1818
const slug = workbook.urlSlug;
1919

2020
return slug ? slug : workbook.id.toString();

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import { INTERNAL_SERVER_ERROR } from '$lib/constants/http-response-status-codes
2525
* <?xml version="1.0" encoding="UTF-8"?>
2626
* <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
2727
* <url>
28+
* <loc>https://atcoder-novisteps.vercel.app/workbooks/2-sat</loc>
29+
* <changefreq>daily</changefreq>
30+
* <priority>0.8</priority>
31+
* </url>
32+
* <url>
2833
* <loc>https://atcoder-novisteps.vercel.app/workbooks/123</loc>
2934
* <changefreq>daily</changefreq>
3035
* <priority>0.8</priority>
@@ -43,8 +48,7 @@ export const GET: RequestHandler = async () => {
4348
publishedWorkBookIds = workbooks
4449
.filter((workbook) => workbook.isPublished)
4550
.map((workbook) => {
46-
// Note: To get the urlSlug, passing an empty string for authorName is sufficient
47-
return getUrlSlugFrom({ ...workbook, authorName: '' });
51+
return getUrlSlugFrom(workbook);
4852
});
4953
} catch (e) {
5054
const errorMessage = e instanceof Error ? e.message : 'Unknown error';

0 commit comments

Comments
 (0)