1
- import React from 'react' ;
2
-
3
- import * as Templates from '../Templates/Pages' ;
4
-
5
- import PageNotFound from '../Errors/404/404' ;
6
- import APIClient from '../../../http/requests' ;
7
- import FrontendPage from '../../Layout/FrontendPage' ;
8
- import { connect } from 'react-redux' ;
9
- import AppConfig from '../../../../app_config/app' ;
10
- import { push } from 'react-router-redux' ;
11
- import Helmet from 'react-helmet' ;
12
- import defaultImage from '../Templates/Pages/home-bg.jpg' ;
13
- import { getTemplateName } from '../../../helpers/PageHelper' ;
1
+ import React from "react" ;
2
+ import * as Templates from "../Templates/Pages" ;
3
+ import PageNotFound from "../Errors/404/404" ;
4
+ import APIClient from "../../../http/requests" ;
5
+ import FrontendPage from "../../Layout/FrontendPage" ;
6
+ import { connect } from "react-redux" ;
7
+ import AppConfig from "../../../../app_config/app" ;
8
+ import { push } from "react-router-redux" ;
9
+ import Helmet from "react-helmet" ;
10
+ import defaultImage from "../Templates/Pages/home-bg.jpg" ;
11
+ import { getTemplateName } from "../../../helpers/PageHelper" ;
14
12
15
13
class Page extends React . Component {
16
14
@@ -23,7 +21,7 @@ class Page extends React.Component {
23
21
}
24
22
25
23
isAdminPage ( ) {
26
- return ( this . props . pathname . substring ( 1 , 6 ) . toLowerCase ( ) === ' admin' )
24
+ return ( this . props . pathname . substring ( 1 , 6 ) . toLowerCase ( ) === " admin" )
27
25
}
28
26
29
27
componentWillMount ( ) {
@@ -35,7 +33,7 @@ class Page extends React.Component {
35
33
loadPageContent ( pathname ) {
36
34
const client = new APIClient ( this . props . dispatch ) ;
37
35
38
- client . get ( ' page' , false , { params : { fullpath : pathname } } ) . then ( ( res ) => {
36
+ client . get ( " page" , false , { params : { fullpath : pathname } } ) . then ( ( res ) => {
39
37
this . resolveDataFetch ( res , this . setPreExistingPageData )
40
38
} , this . rejectDataFetch ) . catch ( this . rejectDataFetch )
41
39
}
@@ -46,7 +44,7 @@ class Page extends React.Component {
46
44
47
45
navigateViaRouter = ( event ) => {
48
46
event . preventDefault ( ) ;
49
- this . props . dispatch ( push ( event . currentTarget . getAttribute ( ' href' ) ) ) ;
47
+ this . props . dispatch ( push ( event . currentTarget . getAttribute ( " href" ) ) ) ;
50
48
}
51
49
52
50
setPreExistingPageData = ( res ) => {
@@ -72,13 +70,13 @@ class Page extends React.Component {
72
70
73
71
addLinkBehaviorToAnchorElements ( anchorElements ) {
74
72
anchorElements . forEach ( ( anchorElement ) => {
75
- anchorElement . addEventListener ( ' click' , this . navigateViaRouter , false ) ;
73
+ anchorElement . addEventListener ( " click" , this . navigateViaRouter , false ) ;
76
74
} )
77
75
}
78
76
79
77
getInteralLinks ( ) {
80
- if ( typeof ( document ) !== ' undefined' ) {
81
- const pageTemplate = document . getElementsByClassName ( ' page' ) ;
78
+ if ( typeof ( document ) !== " undefined" ) {
79
+ const pageTemplate = document . getElementsByClassName ( " page" ) ;
82
80
let internalLinks = [ ] ;
83
81
if ( pageTemplate . length > 0 ) {
84
82
let contentAnchors = pageTemplate [ 0 ] . getElementsByTagName ( "a" ) ;
@@ -100,7 +98,7 @@ class Page extends React.Component {
100
98
if ( res . statusCode && res . statusCode >= 300 ) {
101
99
this . props . updatePageStatusCode ( res . statusCode ) ;
102
100
} else {
103
- console . warn ( ' Error: ' , res )
101
+ console . warn ( " Error: " , res )
104
102
}
105
103
}
106
104
@@ -135,19 +133,19 @@ class Page extends React.Component {
135
133
136
134
makeHelmetMeta ( ) {
137
135
let headerMeta = [
138
- { property : ' og:title' , content : this . state . name } ,
139
- { property : ' og:url' , content : this . getPageURL ( ) } ,
136
+ { property : " og:title" , content : this . state . name } ,
137
+ { property : " og:url" , content : this . getPageURL ( ) } ,
140
138
] ;
141
139
142
140
if ( this . state . image_url ) {
143
- headerMeta . push ( { property : ' og:image' , content : this . state . image_url } ) ;
141
+ headerMeta . push ( { property : " og:image" , content : this . state . image_url } ) ;
144
142
}
145
143
146
144
return headerMeta ;
147
145
}
148
146
149
147
getPageURL ( ) {
150
- return ( typeof ( window ) !== ' undefined' ) ? window . location . href : `${ AppConfig . baseUrl } /${ this . props . pathname } ` ;
148
+ return ( typeof ( window ) !== " undefined" ) ? window . location . href : `${ AppConfig . baseUrl } /${ this . props . pathname } ` ;
151
149
}
152
150
153
151
getPageTitle ( ) {
@@ -179,18 +177,19 @@ const mapDispatchToProps = (dispatch) => {
179
177
return {
180
178
updatePageStatusCode : ( statusCode ) => {
181
179
dispatch ( {
182
- type : ' UPDATE_PAGE_STATUS_CODE' ,
180
+ type : " UPDATE_PAGE_STATUS_CODE" ,
183
181
statusCode
184
182
} )
185
183
} ,
186
184
dispatch
187
185
}
188
- }
186
+ } ;
187
+
189
188
const mapStateToProps = ( state , ownProps ) => {
190
189
return {
191
190
pathname : state . routing . locationBeforeTransitions . pathname ,
192
191
statusCode : state . page . statusCode
193
192
}
194
- }
193
+ } ;
195
194
196
- export default connect ( mapStateToProps , mapDispatchToProps ) ( Page )
195
+ export default connect ( mapStateToProps , mapDispatchToProps ) ( Page ) ;
0 commit comments