diff --git a/CHANGELOG.md b/CHANGELOG.md index a05ea12..a2f88ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.4.0 - 2018-06-06 + +* Improve reusability of component +* Rename `page` prop to `fields` on pages / posts +* Update config.yml with meta object for each item + ## 0.3.1 - 2018-06-01 * Encode CMS image urls diff --git a/cms/cms.js b/cms/cms.js index 5da9f8e..597fa53 100644 --- a/cms/cms.js +++ b/cms/cms.js @@ -25,19 +25,19 @@ const posts = getDocuments('posts') // Preview Templates CMS.registerPreviewTemplate('home-page', ({ entry }) => ( - + )) CMS.registerPreviewTemplate('about-page', ({ entry }) => ( - + )) CMS.registerPreviewTemplate('contact-page', ({ entry }) => ( - + )) CMS.registerPreviewTemplate('blog-page', ({ entry }) => ( - + )) CMS.registerPreviewTemplate('posts', ({ entry }) => ( - + )) // Return to home when user logging out diff --git a/content/postCategories/updates.md b/content/postCategories/updates.md index b411e21..4b47c3e 100644 --- a/content/postCategories/updates.md +++ b/content/postCategories/updates.md @@ -1,3 +1,7 @@ --- title: Updates +meta: + description: Desc + title: Test Updates Title --- + diff --git a/content/posts/hello-world.md b/content/posts/hello-world.md index 6cc5a6f..54d0f52 100644 --- a/content/posts/hello-world.md +++ b/content/posts/hello-world.md @@ -1,8 +1,6 @@ --- title: Hello World! status: Featured / Published -categories: - - category: News date: '2018-03-27' postFeaturedImage: /images/uploads/tim-marshall-155597.jpg excerpt: >- @@ -10,6 +8,13 @@ excerpt: >- interdum arcu vitae augue pulvinar sodales. Sed non dui diam. Quisque lectus est, lobortis ac efficitur vitae, posuere a mauris. Phasellus ac dui pellentesque, lacinia risus ut, imperdiet eros. +categories: + - category: News +meta: + canonicalLink: '' + description: '' + noindex: false + title: '' --- Paragraphs are separated by a blank line. diff --git a/public/admin/config.yml b/public/admin/config.yml index 939fe31..6b25185 100644 --- a/public/admin/config.yml +++ b/public/admin/config.yml @@ -25,6 +25,14 @@ collections: # A list of collections the CMS should be able to edit - {label: Address, name: address, widget: text} - {label: Phone, name: phone, widget: string} - {label: Email Address, name: email, widget: string} + - label: "Meta" + name: "meta" + widget: "object" + fields: + - {label: Title, name: title, widget: string, required: false} + - {label: Description, name: description, widget: text, required: false, pattern: [".{,300}", "Must not exceed 300 characters"]} + - {label: Canonical Link, name: canonicalLink, widget: string, required: false} + - {label: Noindex, name: noindex, widget: boolean, required: false} - file: "content/pages/blog.md" label: "Blog Page" @@ -33,6 +41,14 @@ collections: # A list of collections the CMS should be able to edit - {label: Title, name: title, widget: string} - {label: Featured Image, name: featuredImage, widget: image} - {label: Subtitle, name: subtitle, widget: markdown} + - label: "Meta" + name: "meta" + widget: "object" + fields: + - {label: Title, name: title, widget: string, required: false} + - {label: Description, name: description, widget: text, required: false, pattern: [".{,300}", "Must not exceed 300 characters"]} + - {label: Canonical Link, name: canonicalLink, widget: string, required: false} + - {label: Noindex, name: noindex, widget: boolean, required: false} - file: "content/pages/about.md" label: "About Page" @@ -43,6 +59,14 @@ collections: # A list of collections the CMS should be able to edit - {label: Subtitle, name: subtitle, widget: markdown} - {label: Section 1, name: section1, widget: markdown} - {label: Section 2, name: section2, widget: markdown} + - label: "Meta" + name: "meta" + widget: "object" + fields: + - {label: Title, name: title, widget: string, required: false} + - {label: Description, name: description, widget: text, required: false, pattern: [".{,300}", "Must not exceed 300 characters"]} + - {label: Canonical Link, name: canonicalLink, widget: string, required: false} + - {label: Noindex, name: noindex, widget: boolean, required: false} - file: "content/pages/home.md" label: "Home Page" @@ -52,6 +76,14 @@ collections: # A list of collections the CMS should be able to edit - {label: Featured Image, name: featuredImage, widget: image} - {label: Subtitle, name: subtitle, widget: markdown} - {label: Body, name: body, widget: markdown} + - label: "Meta" + name: "meta" + widget: "object" + fields: + - {label: Title, name: title, widget: string, required: false} + - {label: Description, name: description, widget: text, required: false, pattern: [".{,300}", "Must not exceed 300 characters"]} + - {label: Canonical Link, name: canonicalLink, widget: string, required: false} + - {label: Noindex, name: noindex, widget: boolean, required: false} - name: posts @@ -83,6 +115,14 @@ collections: # A list of collections the CMS should be able to edit collection: "postCategories" searchFields: ["title"] valueField: "title" + - label: "Meta" + name: "meta" + widget: "object" + fields: + - {label: Title, name: title, widget: string, required: false} + - {label: Description, name: description, widget: text, required: false, pattern: [".{,300}", "Must not exceed 300 characters"]} + - {label: Canonical Link, name: canonicalLink, widget: string, required: false} + - {label: Noindex, name: noindex, widget: boolean, required: false} - name: postCategories @@ -94,6 +134,14 @@ collections: # A list of collections the CMS should be able to edit create: true # Allow users to create new documents in this collection fields: # The fields each document in this collection have - {label: Title, name: title, widget: string} + - label: "Meta" + name: "meta" + widget: "object" + fields: + - {label: Title, name: title, widget: string, required: false} + - {label: Description, name: description, widget: text, required: false, pattern: [".{,300}", "Must not exceed 300 characters"]} + - {label: Canonical Link, name: canonicalLink, widget: string, required: false} + - {label: Noindex, name: noindex, widget: boolean, required: false} - name: "settings" diff --git a/src/App.js b/src/App.js index 02958ac..774f80c 100644 --- a/src/App.js +++ b/src/App.js @@ -1,7 +1,6 @@ -import React, { Component } from 'react' +import React, { Component, Fragment } from 'react' import { BrowserRouter as Router, Route, Switch } from 'react-router-dom' import Helmet from 'react-helmet' -import _findIndex from 'lodash/findIndex' import ScrollToTop from './components/ScrollToTop' import Meta from './components/Meta' @@ -19,6 +18,18 @@ import data from './data.json' import { slugify } from './util/url' import { documentHasTerm, getCollectionTerms } from './util/collection' +const RouteWithMeta = ({ component: Component, ...props }) => ( + ( + + + + + )} + /> +) + class App extends Component { state = { data @@ -28,7 +39,7 @@ class App extends Component { 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 globalSettings = this.getDocument('settings', 'global') @@ -59,9 +70,7 @@ class App extends Component { titleTemplate={`${siteTitle} | %s`} /> +