From c07acf5ddf9fe1241b13aac8fbad47e4a96798ee Mon Sep 17 00:00:00 2001 From: swve Date: Fri, 19 May 2023 18:57:58 +0200 Subject: [PATCH] feat: add dynamic metadata for courses page --- .../[orgslug]/(withmenu)/courses/page.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/front/app/orgs/[orgslug]/(withmenu)/courses/page.tsx b/front/app/orgs/[orgslug]/(withmenu)/courses/page.tsx index aa66b09a..17dd3580 100644 --- a/front/app/orgs/[orgslug]/(withmenu)/courses/page.tsx +++ b/front/app/orgs/[orgslug]/(withmenu)/courses/page.tsx @@ -3,12 +3,25 @@ import React from "react"; import Courses from "./courses"; import { getOrgCourses } from "@services/courses/courses"; import { Metadata } from "next"; +import { getOrganizationContextInfo } from "@services/organizations/orgs"; -export const metadata: Metadata = { - title: 'LearnHouse - Courses', - description: 'courses', +type MetadataProps = { + params: { orgslug: string }; + searchParams: { [key: string]: string | string[] | undefined }; }; +export async function generateMetadata( + { params }: MetadataProps, +): Promise { + + // Get Org context information + const org = await getOrganizationContextInfo(params.orgslug, { revalidate: 1800, tags: ['organizations'] }); + return { + title: org.name + " — Courses", + description: org.description, + }; +} + const CoursesPage = async (params: any) => { const orgslug = params.params.orgslug; const courses = await getOrgCourses(orgslug, { revalidate: 360, tags: ['courses'] });