Skip to content

Commit bdd4fd5

Browse files
committed
Fix addon for #3972
1 parent f65488a commit bdd4fd5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/shared/routes/Topcoder/Routes.jsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,21 @@ export default function Topcoder() {
117117
<ContentfulLoader
118118
entryQueries={{
119119
content_type: 'article',
120-
'fields.title': articleTitle,
120+
'fields.title[match]': articleTitle,
121121
}}
122122
spaceName="EDU"
123123
render={(data) => {
124124
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+
}
126135
const { externalArticle, contentUrl } = data.entries.items[id].fields;
127136
if (externalArticle && contentUrl && isomorphy.isClientSide()) {
128137
window.location.href = contentUrl;

0 commit comments

Comments
 (0)