mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add more pages to the sitemap
This commit is contained in:
parent
96af67f9aa
commit
0893e6f9d3
2 changed files with 14 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import { getUriWithOrg } from '@services/config/config';
|
import { getUriWithOrg } from '@services/config/config';
|
||||||
import { getOrgCourses } from '@services/courses/courses';
|
import { getOrgCourses } from '@services/courses/courses';
|
||||||
import { getOrganizationContextInfo } from '@services/organizations/orgs';
|
import { getOrganizationContextInfo } from '@services/organizations/orgs';
|
||||||
|
import { getOrgCollections } from '@services/courses/collections';
|
||||||
import { NextRequest, NextResponse } from 'next/server';
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -13,6 +14,7 @@ export async function GET(request: NextRequest) {
|
||||||
|
|
||||||
const orgInfo = await getOrganizationContextInfo(orgSlug, null);
|
const orgInfo = await getOrganizationContextInfo(orgSlug, null);
|
||||||
const courses = await getOrgCourses(orgSlug, null);
|
const courses = await getOrgCourses(orgSlug, null);
|
||||||
|
const collections = await getOrgCollections(orgInfo.id);
|
||||||
|
|
||||||
const host = request.headers.get('host');
|
const host = request.headers.get('host');
|
||||||
if (!host) {
|
if (!host) {
|
||||||
|
|
@ -23,9 +25,18 @@ export async function GET(request: NextRequest) {
|
||||||
|
|
||||||
const sitemapUrls: SitemapUrl[] = [
|
const sitemapUrls: SitemapUrl[] = [
|
||||||
{ loc: baseUrl, priority: 1.0, changefreq: 'daily' },
|
{ 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 }) => ({
|
...courses.map((course: { course_uuid: string }) => ({
|
||||||
loc: `${baseUrl}course/${course.course_uuid.replace('course_', '')}`,
|
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'
|
changefreq: 'weekly'
|
||||||
}))
|
}))
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,8 @@ export async function getCollectionById(
|
||||||
|
|
||||||
export async function getOrgCollections(
|
export async function getOrgCollections(
|
||||||
org_id: string,
|
org_id: string,
|
||||||
access_token: string,
|
access_token?: string,
|
||||||
next: any
|
next?: any
|
||||||
) {
|
) {
|
||||||
const result: any = await fetch(
|
const result: any = await fetch(
|
||||||
`${getAPIUrl()}collections/org/${org_id}/page/1/limit/10`,
|
`${getAPIUrl()}collections/org/${org_id}/page/1/limit/10`,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue