Skip to content

Commit 227c600

Browse files
committed
Fixes for #4887
1 parent c57652c commit 227c600

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

src/shared/components/Contentful/Article/Article.jsx

+22-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import LoadingIndicator from 'components/LoadingIndicator';
1515
import YouTubeVideo from 'components/YouTubeVideo';
1616
import moment from 'moment';
1717
import localStorage from 'localStorage';
18-
import { config, Link, isomorphy } from 'topcoder-react-utils';
18+
import { Helmet } from 'react-helmet';
19+
import {
20+
config, Link, isomorphy,
21+
} from 'topcoder-react-utils';
1922
import qs from 'qs';
2023
// SVGs and assets
2124
import GestureIcon from 'assets/images/icon-gesture.svg';
@@ -110,9 +113,27 @@ export default class Article extends React.Component {
110113
if (isomorphy.isClientSide()) {
111114
shareUrl = encodeURIComponent(window.location.href);
112115
}
116+
const description = htmlToText.fromString(
117+
ReactDOMServer.renderToString(markdown(fields.content)),
118+
{
119+
ignoreHref: true,
120+
ignoreImage: true,
121+
singleNewLineParagraphs: true,
122+
uppercaseHeadings: false,
123+
},
124+
).substring(0, CONTENT_PREVIEW_LENGTH);
113125

114126
return (
115127
<React.Fragment>
128+
<Helmet>
129+
<title>{fields.title}</title>
130+
<meta name="title" property="og:title" content={fields.title} />
131+
<meta name="description" property="og:description" content={description} />
132+
<meta name="description" property="description" content={description} />
133+
<meta name="twitter:description" content={description} />
134+
<meta name="image" property="og:image" content={fields.featuredImage ? `https:${subData.assets.items[fields.featuredImage.sys.id].fields.file.url}` : null} />
135+
<meta name="twitter:image" content={fields.featuredImage ? `https:${subData.assets.items[fields.featuredImage.sys.id].fields.file.url}` : null} />
136+
</Helmet>
116137
{/* Banner */}
117138
{
118139
fields.featuredImage ? (

src/shared/containers/EDU/Home.jsx

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
import React from 'react';
55
import { config } from 'topcoder-react-utils';
6+
import { Helmet } from 'react-helmet';
67
import Viewport from 'components/Contentful/Viewport';
78
import SearchBar from 'components/Contentful/SearchBar/SearchBar';
89
import { getService } from 'services/contentful';
@@ -45,6 +46,13 @@ export default class EDUHome extends React.Component {
4546
const { taxonomy } = this.state;
4647
return (
4748
<div className={homeTheme.container}>
49+
<Helmet>
50+
<title>THRIVE - Grow with us. Tutorials and workshops that matter.</title>
51+
<meta name="title" property="og:title" content="THRIVE - Grow with us. Tutorials and workshops that matter." />
52+
<meta name="description" property="og:description" content="THRIVE - Grow with us. Tutorials and workshops that matter." />
53+
<meta name="description" property="description" content="THRIVE - Grow with us. Tutorials and workshops that matter." />
54+
<meta name="twitter:description" content="THRIVE - Grow with us. Tutorials and workshops that matter." />
55+
</Helmet>
4856
{/* Banner */}
4957
<div className={homeTheme.bannerContainer}>
5058
<div className={homeTheme.bannerImage} />

src/shared/containers/EDU/Search.jsx

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { updateQuery } from 'utils/url';
1313
import qs from 'qs';
1414
import LoadingIndicator from 'components/LoadingIndicator';
1515
import SearchPageFilter from 'components/Contentful/SearchPageFilter/SearchPageFilter';
16+
import { Helmet } from 'react-helmet';
1617
// Partials
1718
import ResultTabs from './partials/ResultTabs';
1819
// CSS
@@ -91,6 +92,13 @@ export default class EDUSearch extends React.Component {
9192
if (!taxonomy) return <LoadingIndicator />;
9293
return (
9394
<div className={searchTheme.container}>
95+
<Helmet>
96+
<title>THRIVE - Search {`${query.title}`}</title>
97+
<meta name="title" property="og:title" content="THRIVE - Grow with us. Tutorials and workshops that matter." />
98+
<meta name="description" property="og:description" content="THRIVE - Grow with us. Tutorials and workshops that matter." />
99+
<meta name="description" property="description" content="THRIVE - Grow with us. Tutorials and workshops that matter." />
100+
<meta name="twitter:description" content="THRIVE - Grow with us. Tutorials and workshops that matter." />
101+
</Helmet>
94102
{/* Banner */}
95103
<div className={searchTheme.bannerContainer}>
96104
<div className={searchTheme.searchBarWrapp}>

src/shared/containers/EDU/Tracks.jsx

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import qs from 'qs';
1414
import TracksTree from 'components/Contentful/TracksTree/TracksTree';
1515
import LoadingIndicator from 'components/LoadingIndicator';
1616
import TracksFilter from 'components/Contentful/TracksFilter/TracksFilter';
17+
import { Helmet } from 'react-helmet';
1718
// SVGs & Assets
1819
import Dev from 'assets/images/img-development.png';
1920
import Design from 'assets/images/img_design.png';
@@ -167,6 +168,13 @@ export default class EDUTracks extends React.Component {
167168
if (!taxonomy) return <LoadingIndicator />;
168169
return (
169170
<div className={tracksTheme.container}>
171+
<Helmet>
172+
<title>THRIVE - {`${query.track}`}</title>
173+
<meta name="title" property="og:title" content="THRIVE - Grow with us. Tutorials and workshops that matter." />
174+
<meta name="description" property="og:description" content="THRIVE - Grow with us. Tutorials and workshops that matter." />
175+
<meta name="description" property="description" content="THRIVE - Grow with us. Tutorials and workshops that matter." />
176+
<meta name="twitter:description" content="THRIVE - Grow with us. Tutorials and workshops that matter." />
177+
</Helmet>
170178
{/* Banner */}
171179
<div
172180
className={tracksTheme.bannerContainer}

0 commit comments

Comments
 (0)