File tree 1 file changed +11
-2
lines changed
src/shared/routes/Topcoder
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -117,12 +117,21 @@ export default function Topcoder() {
117
117
< ContentfulLoader
118
118
entryQueries = { {
119
119
content_type : 'article' ,
120
- 'fields.title' : articleTitle ,
120
+ 'fields.title[match] ' : articleTitle ,
121
121
} }
122
122
spaceName = "EDU"
123
123
render = { ( data ) => {
124
124
if ( _ . isEmpty ( data . entries . items ) ) return < Error404 /> ;
125
- const id = data . entries . matches [ 0 ] . items [ 0 ] ;
125
+ let id = data . entries . matches [ 0 ] . items [ 0 ] ;
126
+ if ( data . entries . matches [ 0 ] . total !== 1 ) {
127
+ // more than 1 match. we need to try find best
128
+ const mId = _ . findKey (
129
+ data . entries . items ,
130
+ // eslint-disable-next-line max-len
131
+ o => o . fields . title . toLocaleLowerCase ( ) === articleTitle . toLocaleLowerCase ( ) ,
132
+ ) ;
133
+ id = mId || id ;
134
+ }
126
135
const { externalArticle, contentUrl } = data . entries . items [ id ] . fields ;
127
136
if ( externalArticle && contentUrl && isomorphy . isClientSide ( ) ) {
128
137
window . location . href = contentUrl ;
You can’t perform that action at this time.
0 commit comments