Skip to content

Commit ff98ccb

Browse files
committed
Gatsby plugin updates (#107)
1 parent 5017737 commit ff98ccb

12 files changed

+210
-231
lines changed

gatsby-config.js

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ module.exports = {
3131
resolve: 'gatsby-plugin-netlify-cms',
3232
options: {
3333
modulePath: `${__dirname}/src/cms/cms.js`,
34-
stylesPath: `${__dirname}/src/components/all.sass`,
3534
},
3635
},
3736
'gatsby-plugin-netlify', // make sure to keep it last in the array

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"gatsby-transformer-sharp": "next",
1818
"lodash": "^4.17.5",
1919
"lodash-webpack-plugin": "^0.11.4",
20-
"netlify-cms": "^1.9.3",
20+
"netlify-cms": "^2.0.11",
2121
"node-sass": "^4.9.2",
2222
"parcel-bundler": "^1.9.4",
2323
"prop-types": "^15.6.0",
@@ -36,7 +36,7 @@
3636
"clean": "rimraf .cache public",
3737
"build": "npm run clean && gatsby build",
3838
"develop": "npm run clean && gatsby develop",
39-
"serve": "npm run clean && gatsby serve",
39+
"serve": "gatsby serve",
4040
"format": "prettier --trailing-comma es5 --no-semi --single-quote --write \"{gatsby-*.js,src/**/*.js}\"",
4141
"test": "echo \"Error: no test specified\" && exit 1"
4242
},

src/cms/preview-templates/AboutPagePreview.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3-
import AboutPageTemplate from '../../components/AboutPageTemplate'
3+
import { AboutPageTemplate } from '../../templates/about-page'
44

55
const AboutPagePreview = ({ entry, widgetFor }) => (
66
<AboutPageTemplate

src/cms/preview-templates/BlogPostPreview.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3-
import BlogPostTemplate from '../../components/BlogPostTemplate'
3+
import { BlogPostTemplate } from '../../templates/blog-post'
44

55
const BlogPostPreview = ({ entry, widgetFor }) => (
66
<BlogPostTemplate

src/cms/preview-templates/ProductPagePreview.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3-
import ProductPageTemplate from '../../components/ProductPageTemplate'
3+
import { ProductPageTemplate } from '../../templates/product-page'
44

55
const ProductPagePreview = ({ entry, getAsset }) => {
66
const entryBlurbs = entry.getIn(['data', 'intro', 'blurbs'])

src/components/AboutPageTemplate.js

-32
This file was deleted.

src/components/BlogPostTemplate.js

-56
This file was deleted.

src/components/Content.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const Content = ({ content, className }) => (
1010
)
1111

1212
Content.propTypes = {
13-
content: PropTypes.string,
13+
content: PropTypes.node,
1414
className: PropTypes.string,
1515
}
1616

src/components/ProductPageTemplate.js

-132
This file was deleted.

src/templates/about-page.js

+27-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,35 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33
import { graphql } from 'gatsby'
44
import Layout from '../components/Layout'
5-
import AboutPageTemplate from '../components/AboutPageTemplate'
65
import Content, { HTMLContent } from '../components/Content'
76

7+
export const AboutPageTemplate = ({ title, content, contentComponent }) => {
8+
const PageContent = contentComponent || Content
9+
10+
return (
11+
<section className="section section--gradient">
12+
<div className="container">
13+
<div className="columns">
14+
<div className="column is-10 is-offset-1">
15+
<div className="section">
16+
<h2 className="title is-size-3 has-text-weight-bold is-bold-light">
17+
{title}
18+
</h2>
19+
<PageContent className="content" content={content} />
20+
</div>
21+
</div>
22+
</div>
23+
</div>
24+
</section>
25+
)
26+
}
27+
28+
AboutPageTemplate.propTypes = {
29+
title: PropTypes.string.isRequired,
30+
content: PropTypes.string,
31+
contentComponent: PropTypes.func,
32+
}
33+
834
const AboutPage = ({ data }) => {
935
const { markdownRemark: post } = data
1036

src/templates/blog-post.js

+49-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,58 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33
import { kebabCase } from 'lodash'
44
import Helmet from 'react-helmet'
5-
import { graphql } from 'gatsby'
5+
import { graphql, Link } from 'gatsby'
66
import Layout from '../components/Layout'
7-
import BlogPostTemplate from '../components/BlogPostTemplate'
87
import Content, { HTMLContent } from '../components/Content'
98

9+
export const BlogPostTemplate = ({
10+
content,
11+
contentComponent,
12+
description,
13+
tags,
14+
title,
15+
helmet,
16+
}) => {
17+
const PostContent = contentComponent || Content
18+
19+
return (
20+
<section className="section">
21+
{helmet || ''}
22+
<div className="container content">
23+
<div className="columns">
24+
<div className="column is-10 is-offset-1">
25+
<h1 className="title is-size-2 has-text-weight-bold is-bold-light">
26+
{title}
27+
</h1>
28+
<p>{description}</p>
29+
<PostContent content={content} />
30+
{tags && tags.length ? (
31+
<div style={{ marginTop: `4rem` }}>
32+
<h4>Tags</h4>
33+
<ul className="taglist">
34+
{tags.map(tag => (
35+
<li key={tag + `tag`}>
36+
<Link to={`/tags/${kebabCase(tag)}/`}>{tag}</Link>
37+
</li>
38+
))}
39+
</ul>
40+
</div>
41+
) : null}
42+
</div>
43+
</div>
44+
</div>
45+
</section>
46+
)
47+
}
48+
49+
BlogPostTemplate.propTypes = {
50+
content: PropTypes.node.isRequired,
51+
contentComponent: PropTypes.func,
52+
description: PropTypes.string,
53+
title: PropTypes.string,
54+
helmet: PropTypes.instanceOf(Helmet),
55+
}
56+
1057
const BlogPost = ({ data }) => {
1158
const { markdownRemark: post } = data
1259

0 commit comments

Comments
 (0)