@@ -38,16 +38,23 @@ export async function generateMetadata(
3838 const { articleHandle } = await options . params ;
3939 const [ article ] = await persistenceRepository . article . find ( {
4040 where : eq ( "handle" , articleHandle ) ,
41- columns : [ "title" , "excerpt" , "cover_image" , "body" ] ,
41+ columns : [ "title" , "handle" , " excerpt", "cover_image" , "body" ] ,
4242 limit : 1 ,
43+ joins : [
44+ {
45+ table : "users" ,
46+ as : "user" ,
47+ on : {
48+ localField : "author_id" ,
49+ foreignField : "id" ,
50+ } ,
51+ type : "left" ,
52+ columns : [ "id" , "username" , "name" ] ,
53+ } ,
54+ ] ,
4355 } ) ;
4456
45- if ( ! article . cover_image ) {
46- return {
47- title : article . title ,
48- description : removeMarkdownSyntax ( article . body ?? "" , 20 ) ,
49- } ;
50- }
57+ console . log ( article ) ;
5158
5259 return {
5360 title : article . title ,
@@ -56,7 +63,8 @@ export async function generateMetadata(
5663 20
5764 ) ,
5865 openGraph : {
59- url : `https://www.techdiary.dev/@${ article . user ?. username } /${ article . handle } ` ,
66+ title : article . title ,
67+ url : `https://www.techdiary.dev/@${ article ?. user ?. username } /${ article ?. handle } ` ,
6068 type : "article" ,
6169 images : [
6270 {
@@ -78,14 +86,23 @@ const Page: NextPage<ArticlePageProps> = async ({ params }) => {
7886 "@context" : "https://schema.org" ,
7987 "@type" : "Article" ,
8088 name : article ?. title ,
81- image : getFileUrl ( article ?. cover_image ) ,
89+ image : article ?. cover_image ? getFileUrl ( article ?. cover_image ) : undefined ,
8290 description : article ?. excerpt ?? removeMarkdownSyntax ( article ?. body ?? "" ) ,
91+ url : `https://www.techdiary.dev/@${ article ?. user ?. username } /${ article ?. handle } ` ,
8392 author : {
8493 "@type" : "Person" ,
8594 name : article ?. user ?. name ,
8695 image : getFileUrl ( article ?. user ?. profile_photo ) ,
8796 url : `https://www.techdiary.dev/@${ article ?. user ?. username } ` ,
8897 } ,
98+ publisher : {
99+ "@type" : "Organization" ,
100+ name : "TechDiary" ,
101+ logo : {
102+ "@type" : "ImageObject" ,
103+ url : "https://www.techdiary.dev/og.png" ,
104+ } ,
105+ } ,
89106 articleBody : removeMarkdownSyntax ( article ?. body ?? "" , 300 ) ,
90107 } ;
91108
0 commit comments