@@ -24,6 +24,12 @@ import { eq, and, lte } from "drizzle-orm";
2424import FeedArticleContent from "./_feedArticleContent" ;
2525import LinkContentDetail from "./_linkContentDetail" ;
2626import UserLinkDetail from "./_userLinkDetail" ;
27+ import { JsonLd } from "@/components/JsonLd" ;
28+ import {
29+ getArticleSchema ,
30+ getBreadcrumbSchema ,
31+ getNewsArticleSchema ,
32+ } from "@/lib/structured-data" ;
2733
2834type Props = { params : Promise < { username : string ; slug : string } > } ;
2935
@@ -457,8 +463,40 @@ const UnifiedPostPage = async (props: Props) => {
457463 } ) as unknown as string ;
458464 }
459465
466+ // Prepare JSON-LD structured data
467+ const articleSchema = getArticleSchema ( {
468+ title : userPost . title ,
469+ excerpt : userPost . excerpt ,
470+ slug : userPost . slug ,
471+ publishedAt : userPost . published ,
472+ updatedAt : userPost . updatedAt ,
473+ readingTime : userPost . readTimeMins ,
474+ canonicalUrl : userPost . canonicalUrl ,
475+ tags : userPost . tags . map ( ( t ) => ( { title : t . tag . title } ) ) ,
476+ author : {
477+ name : userPost . user . name ,
478+ username : userPost . user . username ,
479+ image : userPost . user . image ,
480+ bio : userPost . user . bio ,
481+ } ,
482+ } ) ;
483+
484+ const breadcrumbSchema = getBreadcrumbSchema ( [
485+ { name : "Home" , url : "https://www.codu.co" } ,
486+ { name : "Feed" , url : "https://www.codu.co/feed" } ,
487+ {
488+ name : userPost . user . name || "Author" ,
489+ url : `https://www.codu.co/${ userPost . user . username } ` ,
490+ } ,
491+ { name : userPost . title } ,
492+ ] ) ;
493+
460494 return (
461495 < >
496+ { /* JSON-LD Structured Data for SEO */ }
497+ < JsonLd data = { articleSchema } />
498+ < JsonLd data = { breadcrumbSchema } />
499+
462500 < div className = "mx-auto max-w-3xl px-4 py-8" >
463501 { /* Breadcrumb navigation */ }
464502 < nav className = "mb-6 flex items-center gap-2 text-sm text-neutral-500 dark:text-neutral-400" >
@@ -618,8 +656,40 @@ const UnifiedPostPage = async (props: Props) => {
618656 } ) as unknown as string ;
619657 }
620658
659+ // Prepare JSON-LD structured data
660+ const articleSchema = getArticleSchema ( {
661+ title : userArticle . title ,
662+ excerpt : userArticle . excerpt ,
663+ slug : userArticle . slug ,
664+ publishedAt : userArticle . publishedAt ,
665+ updatedAt : userArticle . updatedAt ,
666+ readingTime : userArticle . readTimeMins ,
667+ canonicalUrl : userArticle . canonicalUrl ,
668+ tags : userArticle . tags ?. map ( ( t ) => ( { title : t . tag . title } ) ) ,
669+ author : {
670+ name : userArticle . user . name ,
671+ username : userArticle . user . username ,
672+ image : userArticle . user . image ,
673+ bio : userArticle . user . bio ,
674+ } ,
675+ } ) ;
676+
677+ const breadcrumbSchema = getBreadcrumbSchema ( [
678+ { name : "Home" , url : "https://www.codu.co" } ,
679+ { name : "Feed" , url : "https://www.codu.co/feed" } ,
680+ {
681+ name : userArticle . user . name || "Author" ,
682+ url : `https://www.codu.co/${ userArticle . user . username } ` ,
683+ } ,
684+ { name : userArticle . title } ,
685+ ] ) ;
686+
621687 return (
622688 < >
689+ { /* JSON-LD Structured Data for SEO */ }
690+ < JsonLd data = { articleSchema } />
691+ < JsonLd data = { breadcrumbSchema } />
692+
623693 < div className = "mx-auto max-w-3xl px-4 py-8" >
624694 { /* Breadcrumb navigation */ }
625695 < nav className = "mb-6 flex items-center gap-2 text-sm text-neutral-500 dark:text-neutral-400" >
@@ -773,16 +843,78 @@ const UnifiedPostPage = async (props: Props) => {
773843 const feedArticle = await getFeedArticle ( username , slug ) ;
774844
775845 if ( feedArticle ) {
776- // Render feed article
777- return < FeedArticleContent sourceSlug = { username } articleSlug = { slug } /> ;
846+ // Prepare JSON-LD structured data for feed article
847+ const newsArticleSchema = getNewsArticleSchema ( {
848+ title : feedArticle . title ,
849+ excerpt : feedArticle . excerpt ,
850+ slug : feedArticle . slug ,
851+ externalUrl : feedArticle . externalUrl || "" ,
852+ coverImage : feedArticle . imageUrl || feedArticle . ogImageUrl ,
853+ publishedAt : feedArticle . publishedAt ,
854+ source : {
855+ name : feedArticle . source ?. name || null ,
856+ slug : feedArticle . source ?. slug || username ,
857+ logoUrl : feedArticle . source ?. logoUrl ,
858+ } ,
859+ } ) ;
860+
861+ const breadcrumbSchema = getBreadcrumbSchema ( [
862+ { name : "Home" , url : "https://www.codu.co" } ,
863+ { name : "Feed" , url : "https://www.codu.co/feed" } ,
864+ {
865+ name : feedArticle . source ?. name || username ,
866+ url : `https://www.codu.co/${ feedArticle . source ?. slug || username } ` ,
867+ } ,
868+ { name : feedArticle . title } ,
869+ ] ) ;
870+
871+ // Render feed article with JSON-LD
872+ return (
873+ < >
874+ < JsonLd data = { newsArticleSchema } />
875+ < JsonLd data = { breadcrumbSchema } />
876+ < FeedArticleContent sourceSlug = { username } articleSlug = { slug } />
877+ </ >
878+ ) ;
778879 }
779880
780881 // Try unified content table (new LINK type items)
781882 const linkContent = await getLinkContent ( username , slug ) ;
782883
783884 if ( linkContent ) {
784- // Render link content
785- return < LinkContentDetail sourceSlug = { username } contentSlug = { slug } /> ;
885+ // Prepare JSON-LD structured data for link content
886+ const newsArticleSchema = getNewsArticleSchema ( {
887+ title : linkContent . title ,
888+ excerpt : linkContent . excerpt ,
889+ slug : linkContent . slug ,
890+ externalUrl : linkContent . externalUrl || "" ,
891+ coverImage : linkContent . imageUrl || linkContent . ogImageUrl ,
892+ publishedAt : linkContent . publishedAt ,
893+ source : {
894+ name : linkContent . source ?. name || null ,
895+ slug : linkContent . source ?. slug || username ,
896+ logoUrl : linkContent . source ?. logoUrl ,
897+ } ,
898+ } ) ;
899+
900+ const breadcrumbSchema = getBreadcrumbSchema ( [
901+ { name : "Home" , url : "https://www.codu.co" } ,
902+ { name : "Feed" , url : "https://www.codu.co/feed" } ,
903+ {
904+ name : linkContent . source ?. name || username ,
905+ url : `https://www.codu.co/${ linkContent . source ?. slug || username } ` ,
906+ } ,
907+ { name : linkContent . title } ,
908+ ] ) ;
909+
910+ // Render link content with JSON-LD
911+ return (
912+ < >
913+ < JsonLd data = { newsArticleSchema } />
914+ < JsonLd data = { breadcrumbSchema } />
915+ < LinkContentDetail sourceSlug = { username } contentSlug = { slug } />
916+ </ >
917+ ) ;
786918 }
787919
788920 // Nothing found
0 commit comments