diff --git a/package.json b/package.json index cfa0164e..46b491eb 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "fs": "0.0.1-security", "fs-extra": "^2.0.0", "history": "^1.17.0", + "html-entities": "^1.2.1", "http-proxy-middleware": "^0.17.4", "http-server": "^0.8.5", "immutable": "^3.7.6", diff --git a/server.jsx b/server.jsx index 1f30ff24..1a8541d5 100644 --- a/server.jsx +++ b/server.jsx @@ -56,6 +56,10 @@ import { get_related_content } from 'utils/redux_loader'; import redirects_map from './redirects'; +// page meta data decoding +const Entities = require('html-entities').XmlEntities; +const entities = new Entities(); + import {reducer as formReducer} from 'redux-form' @@ -451,6 +455,12 @@ function renderView(store, renderProps, location) { activePageComponent = (activePageComponent.length > 0) ? activePageComponent[0] : null; if (activePageComponent) { meta = extend(meta, activePageComponent.getPageMeta(state)); + meta = { + title: entities.encode(meta.title), + description: entities.encode(meta.description), + author: entities.encode(meta.author), + keywoards: entities.encode(meta.keywoards), + } } return { diff --git a/shared/Blog/Routes/BlogContainer.js b/shared/Blog/Routes/BlogContainer.js index a47cb2bb..3e363761 100644 --- a/shared/Blog/Routes/BlogContainer.js +++ b/shared/Blog/Routes/BlogContainer.js @@ -37,7 +37,7 @@ class BlogContainer extends Component { static getPageMeta() { return { - title: 'Blogs | Data Skeptic' + title: `Blogs | Data Skeptic` } } diff --git a/shared/Blog/Routes/BlogRouter.js b/shared/Blog/Routes/BlogRouter.js index 2d65ba72..35f8ffa1 100644 --- a/shared/Blog/Routes/BlogRouter.js +++ b/shared/Blog/Routes/BlogRouter.js @@ -41,8 +41,6 @@ class BlogRouter extends React.Component { console.log(payload) dispatch({type: "CMS_LOAD_RECENT_BLOGS", payload }) } - //const {title} = BlogRouter.getPageMeta(this.props); - //dispatch(changePageTitle(title)); } componentWillReceiveProps(nextProps) { @@ -63,25 +61,27 @@ class BlogRouter extends React.Component { } static getPageMeta(state) { - const isExists = state.blogs.getIn(['blog_focus', 'blog']); - if (!isExists) { - return { - title: 'Data Skeptic', - description: '' - } - } + var ocms = state.cms.toJS() + var blogs = ocms['recent_blogs'] + + let meta = {} - const post = state.blogs.getIn(['blog_focus', 'blog']).toJS(); - const isEpisode = !isUndefined(post.guid); + if (blogs.length === 0) { + return { + title: 'Blog Not Found' + } + } - let meta = { - //title: `${post.title} | Data Skeptic`, - title: `Data Skeptic`, - description: post.desc - }; + if (blogs.length === 1) { + const post = blogs[0] + const isEpisode = !isUndefined(post.guid) - if (isEpisode) { - meta.image = post.preview; + meta.title = `Data Skeptic` + meta.description = post.desc + + if (isEpisode) { + meta.image = post.preview; + } } return meta; diff --git a/shared/Checkout/Routes/Checkout/Checkout.js b/shared/Checkout/Routes/Checkout/Checkout.js index c139fae3..a0a26b5e 100644 --- a/shared/Checkout/Routes/Checkout/Checkout.js +++ b/shared/Checkout/Routes/Checkout/Checkout.js @@ -23,7 +23,7 @@ class Checkout extends Component { static getPageMeta() { return { - title: 'Checkout | Data Skeptic' + title: `Checkout | Data Skeptic` } } diff --git a/shared/Contacts/Routes/ContactUs.js b/shared/Contacts/Routes/ContactUs.js index 0fdfe875..b746f2b5 100644 --- a/shared/Contacts/Routes/ContactUs.js +++ b/shared/Contacts/Routes/ContactUs.js @@ -22,8 +22,8 @@ class ContactUs extends React.Component { static getPageMeta() { return { - title: 'Contact Us | Data Skeptic', - description: 'We hope to respond to all inquiries, but sometimes the volume of incoming questions can cause our queue to explode. We prioritize responses to Data Skeptic members first, and to those who ask questions in a public forum like Twitter, our Facebook wall (not Facebook direct message), or Slack. Many people can benefit from responses in public places.' + title: `Contact Us | Data Skeptic`, + description: `We hope to respond to all inquiries, but sometimes the volume of incoming questions can cause our queue to explode. We prioritize responses to Data Skeptic members first, and to those who ask questions in a public forum like Twitter, our Facebook wall (not Facebook direct message), or Slack. Many people can benefit from responses in public places.` } } diff --git a/shared/Podcasts/Routes/Podcast.js b/shared/Podcasts/Routes/Podcast.js index beefa306..d9cb55ae 100644 --- a/shared/Podcasts/Routes/Podcast.js +++ b/shared/Podcasts/Routes/Podcast.js @@ -34,7 +34,7 @@ class Podcast extends Component { static getPageMeta() { return { - title: 'Podcasts | Data Skeptic' + title: `Podcasts | Data Skeptic` } } diff --git a/shared/Proposals/Routes/Proposals.js b/shared/Proposals/Routes/Proposals.js index 53d97be4..27cb8c60 100644 --- a/shared/Proposals/Routes/Proposals.js +++ b/shared/Proposals/Routes/Proposals.js @@ -45,7 +45,7 @@ class Proposals extends Component { static getPageMeta() { return { - title: 'Request for Comment | Data Skeptic' + title: `Request for Comment | Data Skeptic` } } diff --git a/shared/Proposals/Routes/ThankYou/ThankYouPage.js b/shared/Proposals/Routes/ThankYou/ThankYouPage.js index 154e1974..181c9435 100644 --- a/shared/Proposals/Routes/ThankYou/ThankYouPage.js +++ b/shared/Proposals/Routes/ThankYou/ThankYouPage.js @@ -18,7 +18,7 @@ class ProposalsThankYouPage extends Component { static getPageMeta() { return { - title: 'Thank you | Data Skeptic' + title: `Thank you | Data Skeptic` } } diff --git a/shared/components/Advertising.js b/shared/components/Advertising.js index 689c6f8f..d5ec296e 100644 --- a/shared/components/Advertising.js +++ b/shared/components/Advertising.js @@ -13,7 +13,7 @@ class Advertising extends Component { static getPageMeta() { return { - title: 'Advertising | Data Skeptic' + title: `Advertising | Data Skeptic` } } diff --git a/shared/components/Analytics.js b/shared/components/Analytics.js index 9ddc7a29..d0c342cf 100644 --- a/shared/components/Analytics.js +++ b/shared/components/Analytics.js @@ -23,7 +23,7 @@ class AnalyticsPage extends Component { static getPageMeta() { return { - title: 'Analytics | Data Skeptic' + title: `Analytics | Data Skeptic` } } diff --git a/shared/components/Home.jsx b/shared/components/Home.jsx index c2cbde8e..dafe258d 100644 --- a/shared/components/Home.jsx +++ b/shared/components/Home.jsx @@ -22,7 +22,7 @@ class Home extends Component { static getPageMeta() { return { - title: 'Data Skeptic' + title: `Data Skeptic` } } diff --git a/shared/components/Login.js b/shared/components/Login.js index a8bdf534..fc15b4a4 100644 --- a/shared/components/Login.js +++ b/shared/components/Login.js @@ -23,7 +23,7 @@ class Login extends Component { static getPageMeta() { return { - title: 'Login | Data Skeptic' + title: `Login | Data Skeptic` } } diff --git a/shared/components/Logout.js b/shared/components/Logout.js index f7bef4d2..86b112f3 100644 --- a/shared/components/Logout.js +++ b/shared/components/Logout.js @@ -21,7 +21,7 @@ class Logout extends Component { static getPageMeta() { return { - title: 'Logout | Data Skeptic' + title: `Logout | Data Skeptic` } } diff --git a/shared/components/Membership.jsx b/shared/components/Membership.jsx index 8d9f2d58..d0a0ddfc 100644 --- a/shared/components/Membership.jsx +++ b/shared/components/Membership.jsx @@ -28,7 +28,7 @@ class Membership extends Component { static getPageMeta() { return { - title: 'Membership | Data Skeptic' + title: `Membership | Data Skeptic` } } diff --git a/shared/components/MembershipPortal.js b/shared/components/MembershipPortal.js index e85758e0..daa40dda 100644 --- a/shared/components/MembershipPortal.js +++ b/shared/components/MembershipPortal.js @@ -29,7 +29,7 @@ class MembershipPortal extends Component { static getPageMeta() { return { - title: 'Membership Portal | Data Skeptic' + title: `Membership Portal | Data Skeptic` } } diff --git a/shared/components/Press.js b/shared/components/Press.js index 37895253..02112158 100644 --- a/shared/components/Press.js +++ b/shared/components/Press.js @@ -14,7 +14,7 @@ class Coaching extends Component { static getPageMeta() { return { - title: 'Coaching | Data Skeptic' + title: `Coaching | Data Skeptic` } } diff --git a/shared/components/Projects.js b/shared/components/Projects.js index 527f1216..0267b419 100644 --- a/shared/components/Projects.js +++ b/shared/components/Projects.js @@ -14,7 +14,7 @@ class Projects extends Component { static getPageMeta() { return { - title: 'Projects | Data Skeptic' + title: `Projects | Data Skeptic` } } diff --git a/shared/components/Services.jsx b/shared/components/Services.jsx index c0b05bad..fb504730 100644 --- a/shared/components/Services.jsx +++ b/shared/components/Services.jsx @@ -19,7 +19,7 @@ class Services extends React.Component { static getPageMeta() { return { - title: 'Services | Data Skeptic' + title: `Services | Data Skeptic` } } diff --git a/shared/components/Store.js b/shared/components/Store.js index c2bb558b..6669182c 100644 --- a/shared/components/Store.js +++ b/shared/components/Store.js @@ -26,7 +26,7 @@ class Store extends React.Component { static getPageMeta() { return { - title: 'Store | Data Skeptic' + title: `Store | Data Skeptic` } } diff --git a/views/index.ejs b/views/index.ejs index fb8f6edd..e56eef3c 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -8,9 +8,10 @@