@@ -117,9 +117,20 @@ export function ContentCard({ article }) {
117
117
// Simple check for external links
118
118
const isExternalLink = slug ?. startsWith ( 'http://' ) || slug ?. startsWith ( 'https://' ) ;
119
119
120
- // For external links, use the slug directly
121
- // For internal links, use the slug as is - the parent component should provide the full path
122
- const href = isExternalLink ? slug : slug || '#' ;
120
+ let calculatedHref = '#' ;
121
+ if ( isExternalLink ) {
122
+ calculatedHref = slug ;
123
+ } else if ( slug ) {
124
+ if ( type === 'comparison' ) {
125
+ // Ensure no double slashes if slug might accidentally have one (it shouldn't from our generator)
126
+ calculatedHref = `/comparisons/${ slug . startsWith ( '/' ) ? slug . substring ( 1 ) : slug } ` ;
127
+ } else {
128
+ // For other internal links, assume slug is the intended href.
129
+ // If it's not a full path (e.g. /blog/my-post) Link component will resolve it relatively.
130
+ // If it is a full path (e.g. /blog/my-post), Link will use it as is.
131
+ calculatedHref = slug ;
132
+ }
133
+ }
123
134
124
135
// Format the date
125
136
const formattedDate = date ? new Date ( date ) . toLocaleDateString ( 'en-US' , {
@@ -167,7 +178,7 @@ export function ContentCard({ article }) {
167
178
: "shadow-lg hover:shadow-xl border-gray-200 dark:border-gray-700"
168
179
) } >
169
180
{ isExternalLink ? (
170
- < a href = { href } target = "_blank" rel = "noopener noreferrer" className = "group w-full" >
181
+ < a href = { calculatedHref } target = "_blank" rel = "noopener noreferrer" className = "group w-full" >
171
182
< CardContent
172
183
imageSource = { imageSource }
173
184
title = { title }
@@ -182,7 +193,7 @@ export function ContentCard({ article }) {
182
193
/>
183
194
</ a >
184
195
) : (
185
- < Link href = { href } className = "group w-full" >
196
+ < Link href = { calculatedHref } className = "group w-full" >
186
197
< CardContent
187
198
imageSource = { imageSource }
188
199
title = { title }
0 commit comments