Skip to content

Commit 2a9b747

Browse files
fix: fix the bug when share courses
1 parent 25ff55d commit 2a9b747

File tree

1 file changed

+20
-0
lines changed
  • src/app/learn/[type]/[id]/[chapter_id]

1 file changed

+20
-0
lines changed

src/app/learn/[type]/[id]/[chapter_id]/page.js

+20
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ import { Steper } from './Steper';
2020
import { Content } from './Content';
2121
import { PostTime } from './PostTime';
2222

23+
export async function generateMetadata({ params }) {
24+
const { data } = await get(`v1/learn/course/${params.type === 'courses' ? 'opencourse' : 'challenges'}/${params.id}`, {isServer: true});
25+
const previousImages = `https://file-cdn.openbuild.xyz${data?.base?.course_series_img}` || '';
26+
return {
27+
title: data?.base?.course_series_title,
28+
description: data?.base?.course_series_summary,
29+
openGraph: {
30+
title: data?.base?.course_series_title,
31+
description: data?.base?.course_series_summary,
32+
images: [previousImages],
33+
},
34+
twitter: {
35+
card: 'summary_large_image',
36+
title: data?.base?.course_series_title,
37+
description: data?.base?.course_series_summary,
38+
images: [previousImages],
39+
},
40+
};
41+
}
42+
2343
export default async function ChapterPage({ params }) {
2444
const datas = await Promise.all([
2545
get(`v1/learn/course/${params.type === 'courses' ? 'opencourse' : 'challenges'}/${params.id}`, {isServer: true}),

0 commit comments

Comments
 (0)