From 96bf6ed4603ae9bc0300cfaabfaf26506cabf85b Mon Sep 17 00:00:00 2001 From: Eric Jinks Date: Wed, 22 Nov 2017 15:55:20 +1000 Subject: [PATCH] Add Social Meta to --- public/admin/config.yml | 4 +++ src/App.js | 52 +++++++++++++++++++++++++++++------- src/components/SocialMeta.js | 27 +++++++++++++++++++ src/views/Contact.js | 2 +- 4 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 src/components/SocialMeta.js diff --git a/public/admin/config.yml b/public/admin/config.yml index aa3b1fd..9d17a5f 100644 --- a/public/admin/config.yml +++ b/public/admin/config.yml @@ -18,6 +18,10 @@ collections: # A list of collections the CMS should be able to edit name: "global-settings" fields: - {label: Site Title, name: siteTitle, widget: string} + - {label: Site Url, name: siteUrl, widget: string, required: false} + - {label: Social Media Card Image, name: siteCardImage, widget: image, required: false} + - {label: Twitter Site Account, name: twitterSiteAccount, widget: string, required: false} + - {label: Twitter Creator Account, name: twitterCreatorAccount, widget: string, required: false} - name: "pages" label: "Pages" files: diff --git a/src/App.js b/src/App.js index 1da91b5..6262b58 100644 --- a/src/App.js +++ b/src/App.js @@ -3,6 +3,7 @@ import { BrowserRouter as Router, Route, Switch } from 'react-router-dom' import Helmet from 'react-helmet' import ScrollToTop from './components/ScrollToTop' +import SocialMeta from './components/SocialMeta' import Home from './views/Home' import About from './views/About' import Contact from './views/Contact' @@ -24,29 +25,60 @@ class App extends Component { } getDocument = (collection, name) => - this.state.data[collection] && this.state.data[collection].filter(page => page.name === name)[0] + this.state.data[collection] && + this.state.data[collection].filter(page => page.name === name)[0] - getDocuments = (collection) => this.state.data[collection] + getDocuments = collection => this.state.data[collection] render () { - const site = this.getDocument('settings', 'global') + const { + siteTitle, + siteUrl, + siteDescription, + siteCardImage, + twitterSiteAccount, + twitterCreatorAccount + } = this.getDocument('settings', 'global') return (
- + +