Skip to content

Commit b99249b

Browse files
committed
Implement #3852
1 parent 691f83e commit b99249b

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/shared/components/Contentful/SearchBar/SearchBar.jsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ export class SearchBarInner extends Component {
153153
key={`${item.title}-${item.content}-${item.featuredImage}`}
154154
className={theme['group-cell']}
155155
>
156-
<a className={theme.articleLink} href={`${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.title}`}>
156+
<a
157+
className={theme.articleLink}
158+
href={(item.externalArticle && item.contentUrl) ? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.title}`}
159+
target={(item.externalArticle && item.contentUrl) ? '_blank' : '_self'}
160+
>
157161
{
158162
item.featuredImage ? (
159163
<img
@@ -189,7 +193,11 @@ export class SearchBarInner extends Component {
189193
key={`${item.title}-${item.content}-${item.featuredImage}`}
190194
className={theme['group-cell']}
191195
>
192-
<a className={theme.articleLink} href={`${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.title}`}>
196+
<a
197+
className={theme.articleLink}
198+
href={(item.externalArticle && item.contentUrl) ? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.title}`}
199+
target={(item.externalArticle && item.contentUrl) ? '_blank' : '_self'}
200+
>
193201
{
194202
item.featuredImage ? (
195203
<div className={theme['cell-image']}>
@@ -227,7 +235,11 @@ export class SearchBarInner extends Component {
227235
key={`${item.title}-${item.content}-${item.featuredImage}`}
228236
className={theme['group-cell']}
229237
>
230-
<a className={theme.forumLink} href={`${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.title}`}>
238+
<a
239+
className={theme.forumLink}
240+
href={(item.externalArticle && item.contentUrl) ? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.title}`}
241+
target={(item.externalArticle && item.contentUrl) ? '_blank' : '_self'}
242+
>
231243
<span className={theme['cell-text']}>
232244
{item.title}
233245
</span>
@@ -360,6 +372,8 @@ export class SearchBarInner extends Component {
360372
featuredImage: featuredImage.fields.file.url,
361373
tags: fields.tags,
362374
contentAuthor: contentAuthor.fields,
375+
externalArticle: fields.externalArticle,
376+
contentUrl: fields.contentUrl,
363377
};
364378
}),
365379
'type',

src/shared/routes/Topcoder/Routes.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import ReviewOpportunityDetails from 'routes/ReviewOpportunityDetails';
1717
import Submission from 'routes/Submission';
1818
import SubmissionManagement from 'routes/SubmissionManagement';
1919
import { Route, Switch } from 'react-router-dom';
20-
import { config } from 'topcoder-react-utils';
20+
import { config, isomorphy } from 'topcoder-react-utils';
2121
import ContentfulLoader from 'containers/ContentfulLoader';
2222
import LoadingIndicator from 'components/LoadingIndicator';
2323
import Article from 'components/Contentful/Article';
@@ -120,6 +120,11 @@ export default function Topcoder() {
120120
render={(data) => {
121121
if (_.isEmpty(data.entries.items)) return <Error404 />;
122122
const id = data.entries.matches[0].items[0];
123+
const { externalArticle, contentUrl } = data.entries.items[id].fields;
124+
if (externalArticle && contentUrl && isomorphy.isClientSide()) {
125+
window.location.href = contentUrl;
126+
return null;
127+
}
123128
return (
124129
<Article
125130
id={id}

0 commit comments

Comments
 (0)