File tree Expand file tree Collapse file tree 6 files changed +85
-1
lines changed Expand file tree Collapse file tree 6 files changed +85
-1
lines changed Original file line number Diff line number Diff line change 51
51
"raw-loader" : " 4.0.2" ,
52
52
"react" : " 17.0.2" ,
53
53
"react-dom" : " 17.0.2" ,
54
+ "react-helmet" : " 6.1.0" ,
54
55
"react-redux" : " 7.2.9" ,
55
56
"react-router" : " 6.18.0" ,
56
57
"react-router-dom" : " 6.18.0" ,
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
3
+ import { Helmet } from 'react-helmet' ;
4
+
5
+ import { getConfig } from '@edx/frontend-platform' ;
6
+ import { injectIntl , intlShape } from '@edx/frontend-platform/i18n' ;
7
+
8
+ import messages from './messages' ;
9
+
10
+ const Head = ( { intl } ) => (
11
+ < Helmet >
12
+ < title >
13
+ { intl . formatMessage ( messages [ 'discussions.page.title' ] , { siteName : getConfig ( ) . SITE_NAME } ) }
14
+ </ title >
15
+ < link rel = "shortcut icon" href = { getConfig ( ) . FAVICON_URL } type = "image/x-icon" />
16
+ </ Helmet >
17
+ ) ;
18
+
19
+ Head . propTypes = {
20
+ intl : intlShape . isRequired ,
21
+ } ;
22
+
23
+ export default injectIntl ( Head ) ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
3
+ import { render } from '@testing-library/react' ;
4
+ import { Helmet } from 'react-helmet' ;
5
+
6
+ import { getConfig } from '@edx/frontend-platform' ;
7
+ import { IntlProvider } from '@edx/frontend-platform/i18n' ;
8
+
9
+ import Head from './Head' ;
10
+
11
+ describe ( 'Head' , ( ) => {
12
+ const props = { } ;
13
+ it ( 'should match render title tag and favicon with the site configuration values' , ( ) => {
14
+ render ( < IntlProvider locale = "en" > < Head { ...props } /> </ IntlProvider > ) ;
15
+ const helmet = Helmet . peek ( ) ;
16
+ expect ( helmet . title ) . toEqual ( `Discussions | ${ getConfig ( ) . SITE_NAME } ` ) ;
17
+ expect ( helmet . linkTags [ 0 ] . rel ) . toEqual ( 'shortcut icon' ) ;
18
+ expect ( helmet . linkTags [ 0 ] . href ) . toEqual ( getConfig ( ) . FAVICON_URL ) ;
19
+ } ) ;
20
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { defineMessages } from '@edx/frontend-platform/i18n' ;
2
+
3
+ const messages = defineMessages ( {
4
+ 'discussions.page.title' : {
5
+ id : 'discussions.page.title' ,
6
+ defaultMessage : 'Discussions | {siteName}' ,
7
+ description : 'Title tag' ,
8
+ } ,
9
+ } ) ;
10
+
11
+ export default messages ;
Original file line number Diff line number Diff line change @@ -10,16 +10,17 @@ import {
10
10
} from '@edx/frontend-platform' ;
11
11
import { AppProvider , ErrorPage } from '@edx/frontend-platform/react' ;
12
12
13
+ import Head from './components/Head/Head' ;
13
14
import { DiscussionsHome } from './discussions' ;
14
15
import messages from './i18n' ;
15
16
import store from './store' ;
16
17
17
- import './assets/favicon.ico' ;
18
18
import './index.scss' ;
19
19
20
20
subscribe ( APP_READY , ( ) => {
21
21
ReactDOM . render (
22
22
< AppProvider store = { store } >
23
+ < Head />
23
24
< DiscussionsHome />
24
25
</ AppProvider > ,
25
26
document . getElementById ( 'root' ) ,
You can’t perform that action at this time.
0 commit comments