@@ -8,16 +8,17 @@ import {
88 getPublishedGrammarLessonBundleBySlug ,
99 listPublishedGrammarLessons ,
1010} from "@/features/grammar/lib/grammarDataset" ;
11+ import { buildLessonOpenGraphImageUrl } from "@/features/grammar/lib/lessonOpenGraph" ;
1112import { getGrammarLessonPath } from "@/features/grammar/lib/grammarPaths" ;
1213import {
1314 createLanguageAlternates ,
1415 getGrammarPath ,
1516 getLocalizedHomePath ,
16- getOpenGraphLocale ,
1717} from "@/lib/locale" ;
1818import { getTranslation } from "@/lib/i18n" ;
19+ import { createPageSocialMetadata , createSocialImage } from "@/lib/metadata" ;
1920import { resolvePublicLocale } from "@/lib/publicLocaleRouting" ;
20- import { buildPageTitle , siteConfig } from "@/lib/site" ;
21+ import { siteConfig } from "@/lib/site" ;
2122import {
2223 createBreadcrumbStructuredData ,
2324 createGrammarLessonStructuredData ,
@@ -58,6 +59,14 @@ export async function generateMetadata({
5859 const title = buildGrammarLessonSeoTitle ( lessonBundle . lesson , locale ) ;
5960 const description = buildGrammarLessonSeoDescription ( lessonBundle , locale ) ;
6061 const path = getGrammarLessonPath ( lessonBundle . lesson . slug , locale ) ;
62+ const imageUrl = buildLessonOpenGraphImageUrl (
63+ lessonBundle . lesson . slug ,
64+ locale ,
65+ ) ;
66+ const image = createSocialImage (
67+ imageUrl ,
68+ `${ lessonBundle . lesson . title [ locale ] } | ${ siteConfig . brandName } Grammar` ,
69+ ) ;
6170
6271 return {
6372 metadataBase : new URL ( siteConfig . liveUrl ) ,
@@ -69,16 +78,13 @@ export async function generateMetadata({
6978 `/grammar/${ lessonBundle . lesson . slug } ` ,
7079 ) ,
7180 } ,
72- openGraph : {
73- title : buildPageTitle ( title ) ,
81+ ... createPageSocialMetadata ( {
82+ title,
7483 description,
75- url : `${ siteConfig . liveUrl } ${ path } ` ,
76- locale : getOpenGraphLocale ( locale ) ,
77- } ,
78- twitter : {
79- title : buildPageTitle ( title ) ,
80- description,
81- } ,
84+ path,
85+ locale,
86+ images : [ image ] ,
87+ } ) ,
8288 } ;
8389}
8490
0 commit comments