From 0893e6f9d306f4f8ea8cd9411bc93f7e37626947 Mon Sep 17 00:00:00 2001 From: swve Date: Fri, 27 Sep 2024 18:36:21 +0200 Subject: [PATCH] feat: add more pages to the sitemap --- apps/web/app/api/sitemap/route.ts | 13 ++++++++++++- apps/web/services/courses/collections.ts | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/web/app/api/sitemap/route.ts b/apps/web/app/api/sitemap/route.ts index b457ec29..82a75aba 100644 --- a/apps/web/app/api/sitemap/route.ts +++ b/apps/web/app/api/sitemap/route.ts @@ -1,6 +1,7 @@ import { getUriWithOrg } from '@services/config/config'; import { getOrgCourses } from '@services/courses/courses'; import { getOrganizationContextInfo } from '@services/organizations/orgs'; +import { getOrgCollections } from '@services/courses/collections'; import { NextRequest, NextResponse } from 'next/server'; @@ -13,6 +14,7 @@ export async function GET(request: NextRequest) { const orgInfo = await getOrganizationContextInfo(orgSlug, null); const courses = await getOrgCourses(orgSlug, null); + const collections = await getOrgCollections(orgInfo.id); const host = request.headers.get('host'); if (!host) { @@ -23,9 +25,18 @@ export async function GET(request: NextRequest) { const sitemapUrls: SitemapUrl[] = [ { loc: baseUrl, priority: 1.0, changefreq: 'daily' }, + { loc: `${baseUrl}collections`, priority: 0.9, changefreq: 'weekly' }, + { loc: `${baseUrl}courses`, priority: 0.9, changefreq: 'weekly' }, + // Courses ...courses.map((course: { course_uuid: string }) => ({ loc: `${baseUrl}course/${course.course_uuid.replace('course_', '')}`, - priority: 0.8, + priority: 0.7, + changefreq: 'weekly' + })), + // Collections + ...collections.map((collection: { collection_uuid: string }) => ({ + loc: `${baseUrl}collections/${collection.collection_uuid.replace('collection_', '')}`, + priority: 0.6, changefreq: 'weekly' })) ]; diff --git a/apps/web/services/courses/collections.ts b/apps/web/services/courses/collections.ts index 93051fbf..fb67264a 100644 --- a/apps/web/services/courses/collections.ts +++ b/apps/web/services/courses/collections.ts @@ -46,8 +46,8 @@ export async function getCollectionById( export async function getOrgCollections( org_id: string, - access_token: string, - next: any + access_token?: string, + next?: any ) { const result: any = await fetch( `${getAPIUrl()}collections/org/${org_id}/page/1/limit/10`,