@@ -33,23 +33,21 @@ type TimelineComment = NonNullable<RouterOutputs['comment']['timeline']>;
3333/**
3434 * Creates a JSON-LD comment structure recursively for a comment and its replies
3535 */
36- function createCommentJsonLd (
37- comment : TimelineComment ,
38- pageUrl : string ,
39- ) : Comment | null {
36+ function createCommentJsonLd ( comment : TimelineComment ) : Comment | null {
4037 const author : Person = {
4138 '@type' : 'Person' ,
4239 name : comment . user . name || '' ,
4340 image : comment . user . image || undefined ,
4441 } ;
4542
43+ const jsonldUrl = `https://chirpy.dev/widget/comment/timeline/${ comment . id } ` ;
4644 const commentJsonLd : Comment = {
4745 '@type' : 'Comment' ,
4846 text : getTextFromRteValue ( comment . content as RTEValue ) ,
4947 dateCreated : comment . createdAt . toISOString ( ) ,
5048 author : author ,
51- url : ` ${ pageUrl } #comment- ${ comment . id } ` ,
52- mainEntityOfPage : pageUrl ,
49+ url : jsonldUrl ,
50+ mainEntityOfPage : jsonldUrl ,
5351 } ;
5452
5553 // Add likes information if available
@@ -65,14 +63,14 @@ function createCommentJsonLd(
6563 if ( comment . parentId ) {
6664 commentJsonLd . parentItem = {
6765 '@type' : 'Comment' ,
68- url : `${ pageUrl } # comment- ${ comment . parentId } ` ,
66+ url : `https://chirpy.dev/widget/ comment/timeline/ ${ comment . parentId } ` ,
6967 } as Comment ;
7068 }
7169
7270 // Recursively process replies (if they exist in the timeline data)
7371 if ( comment . replies && comment . replies . length > 0 ) {
7472 commentJsonLd . comment = comment . replies
75- . map ( ( reply : any ) => createCommentJsonLd ( reply , pageUrl ) )
73+ . map ( ( reply : any ) => createCommentJsonLd ( reply ) )
7674 . filter ( Boolean ) as Comment [ ] ;
7775 }
7876
@@ -93,9 +91,7 @@ export function CommentTimelineWidget(
9391 ) ;
9492
9593 // Generate JSON-LD data for the comment timeline
96- const jsonLdData = comment
97- ? createCommentJsonLd ( comment , props . page . url )
98- : null ;
94+ const jsonLdData = comment ? createCommentJsonLd ( comment ) : null ;
9995
10096 return (
10197 < WidgetLayout widgetTheme = { props . theme } title = "Comment timeline" >
0 commit comments