Skip to content

Commit

Permalink
Merge pull request #1 from AustinGreen/master
Browse files Browse the repository at this point in the history
Update Fork
  • Loading branch information
iamfeek committed May 4, 2018
2 parents 89ed0b6 + 816174d commit 3dbd434
Show file tree
Hide file tree
Showing 21 changed files with 360 additions and 13 deletions.
31 changes: 30 additions & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const _ = require('lodash')
const path = require('path')
const { createFilePath } = require('gatsby-source-filesystem')

Expand All @@ -14,6 +15,7 @@ exports.createPages = ({ boundActionCreators, graphql }) => {
slug
}
frontmatter {
tags
templateKey
}
}
Expand All @@ -26,10 +28,13 @@ exports.createPages = ({ boundActionCreators, graphql }) => {
return Promise.reject(result.errors)
}

result.data.allMarkdownRemark.edges.forEach(edge => {
const posts = result.data.allMarkdownRemark.edges

posts.forEach(edge => {
const id = edge.node.id
createPage({
path: edge.node.fields.slug,
tags: edge.node.frontmatter.tags,
component: path.resolve(
`src/templates/${String(edge.node.frontmatter.templateKey)}.js`
),
Expand All @@ -39,6 +44,30 @@ exports.createPages = ({ boundActionCreators, graphql }) => {
},
})
})

// Tag pages:
let tags = []
// Iterate through each post, putting all found tags into `tags`
posts.forEach(edge => {
if (_.get(edge, `node.frontmatter.tags`)) {
tags = tags.concat(edge.node.frontmatter.tags)
}
})
// Eliminate duplicate tags
tags = _.uniq(tags)

// Make tag pages
tags.forEach(tag => {
const tagPath = `/tags/${_.kebabCase(tag)}/`

createPage({
path: tagPath,
component: path.resolve(`src/templates/tags.js`),
context: {
tag,
},
})
})
})
}

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-starter-netlify-cms",
"description": "Example Gatsby, and Netlify CMS project",
"version": "1.1.0",
"version": "1.1.1",
"author": "Austin Green",
"dependencies": {
"bulma": "^0.6.0",
Expand All @@ -15,6 +15,8 @@
"gatsby-source-filesystem": "^1.5.23",
"gatsby-transformer-remark": "^1.7.33",
"gatsby-transformer-sharp": "^1.6.21",
"lodash": "^4.17.5",
"lodash-webpack-plugin": "^0.11.4",
"prop-types": "^15.6.0",
"react": "^16.2.0",
"react-helmet": "^5.2.0"
Expand Down
8 changes: 8 additions & 0 deletions src/cms/preview-templates/AboutPagePreview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import PropTypes from 'prop-types'
import { AboutPageTemplate } from '../../templates/about-page'

const AboutPagePreview = ({ entry, widgetFor }) => (
Expand All @@ -8,4 +9,11 @@ const AboutPagePreview = ({ entry, widgetFor }) => (
/>
)

AboutPagePreview.propTypes = {
entry: PropTypes.shape({
getIn: PropTypes.func,
}),
widgetFor: PropTypes.func,
}

export default AboutPagePreview
9 changes: 9 additions & 0 deletions src/cms/preview-templates/BlogPostPreview.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import React from 'react'
import PropTypes from 'prop-types'
import { BlogPostTemplate } from '../../templates/blog-post'

const BlogPostPreview = ({ entry, widgetFor }) => (
<BlogPostTemplate
content={widgetFor('body')}
description={entry.getIn(['data', 'description'])}
tags={entry.getIn(['data', 'tags'])}
title={entry.getIn(['data', 'title'])}
/>
)

BlogPostPreview.propTypes = {
entry: PropTypes.shape({
getIn: PropTypes.func,
}),
widgetFor: PropTypes.func,
}

export default BlogPostPreview
8 changes: 8 additions & 0 deletions src/cms/preview-templates/ProductPagePreview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import PropTypes from 'prop-types'
import { ProductPageTemplate } from '../../templates/product-page'

const ProductPagePreview = ({ entry, getAsset }) => {
Expand Down Expand Up @@ -45,4 +46,11 @@ const ProductPagePreview = ({ entry, getAsset }) => {
)
}

ProductPagePreview.propTypes = {
entry: PropTypes.shape({
getIn: PropTypes.func,
}),
getAsset: PropTypes.func,
}

export default ProductPagePreview
17 changes: 14 additions & 3 deletions src/components/Content.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import React from 'react'
import PropTypes from 'prop-types'

export default ({ content, className }) => (
<div className={className}>{content}</div>
)
export const HTMLContent = ({ content, className }) => (
<div className={className} dangerouslySetInnerHTML={{ __html: content }} />
)

const Content = ({ content, className }) => (
<div className={className}>{content}</div>
)

Content.propTypes = {
content: PropTypes.string,
className: PropTypes.string,
}

HTMLContent.propTypes = Content.propTypes

export default Content
10 changes: 10 additions & 0 deletions src/components/Features.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import PropTypes from 'prop-types'

const FeatureGrid = ({ gridItems }) => (
<div className="columns is-multiline">
Expand All @@ -15,4 +16,13 @@ const FeatureGrid = ({ gridItems }) => (
</div>
)

FeatureGrid.propTypes = {
gridItems: PropTypes.arrayOf(
PropTypes.shape({
image: PropTypes.string,
text: PropTypes.string,
})
),
}

export default FeatureGrid
16 changes: 15 additions & 1 deletion src/components/Pricing.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'

export default ({ data }) => (
const Pricing = ({ data }) => (
<div className="columns">
{data.map(price => (
<div key={price.plan} className="column">
Expand All @@ -24,3 +25,16 @@ export default ({ data }) => (
))}
</div>
)

Pricing.propTypes = {
data: PropTypes.arrayOf(
PropTypes.shape({
plan: PropTypes.string,
price: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
description: PropTypes.string,
items: PropTypes.array,
})
),
}

export default Pricing
14 changes: 13 additions & 1 deletion src/components/Testimonials.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'

export default ({ testimonials }) => (
const Testimonials = ({ testimonials }) => (
<div>
{testimonials.map(testimonial => (
<article className="message">
Expand All @@ -13,3 +14,14 @@ export default ({ testimonials }) => (
))}
</div>
)

Testimonials.propTypes = {
testimonials: PropTypes.arrayOf(
PropTypes.shape({
quote: PropTypes.string,
author: PropTypes.string,
})
),
}

export default Testimonials
15 changes: 15 additions & 0 deletions src/layouts/all.sass
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ $kaldi-red-invert: #fff
$primary: $kaldi-red
$primary-invert: $kaldi-red-invert

.content .taglist
list-style: none
margin-bottom: 0
margin-left: 0
margin-right: 1.5rem
margin-top: 1.5rem
display: flex
flex-wrap: wrap
justify-content: left
align-items: center
li
padding: 0 2rem 1rem 0
margin-bottom: 1.5rem
margin-top: 0

// Helper Classes
.full-width-image-container
width: 100vw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ templateKey: blog-post
title: Making sense of the SCAA’s new Flavor Wheel
date: 2016-12-17T15:04:10.000Z
description: The Coffee Taster’s Flavor Wheel, the official resource used by coffee tasters, has been revised for the first time this year.
tags:
- flavor
- tasting
---

![flavor wheel](/img/flavor_wheel.jpg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ templateKey: blog-post
title: A beginners’ guide to brewing with Chemex
date: 2017-01-04T15:04:10.000Z
description: Brewing with a Chemex probably seems like a complicated, time-consuming ordeal, but once you get used to the process, it becomes a soothing ritual that's worth the effort every time.
tags:
- brewing
- chemex
---
![chemex](/img/chemex.jpg)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ date: 2017-01-04T15:04:10.000Z
description: >-
We’re proud to announce that we’ll be offering a small batch of Jamaica Blue
Mountain coffee beans in our store next week.
tags:
- jamaica
- green beans
- flavor
- tasting
---

We expect the shipment of a limited quantity of green beans next Monday. We’ll be offering the roasted beans from Tuesday, but quantities are limited, so be quick.
Expand Down
9 changes: 9 additions & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import PropTypes from 'prop-types'
import Link from 'gatsby-link'

export default class IndexPage extends React.Component {
Expand Down Expand Up @@ -43,6 +44,14 @@ export default class IndexPage extends React.Component {
}
}

IndexPage.propTypes = {
data: PropTypes.shape({
allMarkdownRemark: PropTypes.shape({
edges: PropTypes.array,
}),
}),
}

export const pageQuery = graphql`
query IndexQuery {
allMarkdownRemark(sort: { order: DESC, fields: [frontmatter___date] }) {
Expand Down
49 changes: 49 additions & 0 deletions src/pages/tags/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react'
import { kebabCase } from 'lodash'
import Helmet from 'react-helmet'
import Link from 'gatsby-link'

const TagsPage = ({
data: { allMarkdownRemark: { group }, site: { siteMetadata: { title } } },
}) => (
<section className="section">
<Helmet title={`Tags | ${title}`} />
<div className="container content">
<div className="columns">
<div
className="column is-10 is-offset-1"
style={{ marginBottom: '6rem' }}
>
<h1 className="title is-size-2 is-bold-light">Tags</h1>
<ul className="taglist">
{group.map(tag => (
<li key={tag.fieldValue}>
<Link to={`/tags/${kebabCase(tag.fieldValue)}/`}>
{tag.fieldValue} ({tag.totalCount})
</Link>
</li>
))}
</ul>
</div>
</div>
</div>
</section>
)

export default TagsPage

export const tagPageQuery = graphql`
query TagsQuery {
site {
siteMetadata {
title
}
}
allMarkdownRemark(limit: 1000) {
group(field: frontmatter___tags) {
fieldValue
totalCount
}
}
}
`
15 changes: 14 additions & 1 deletion src/templates/about-page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import PropTypes from 'prop-types'
import Content, { HTMLContent } from '../components/Content'

export const AboutPageTemplate = ({ title, content, contentComponent }) => {
Expand All @@ -22,7 +23,13 @@ export const AboutPageTemplate = ({ title, content, contentComponent }) => {
)
}

export default ({ data }) => {
AboutPageTemplate.propTypes = {
title: PropTypes.string.isRequired,
content: PropTypes.string,
contentComponent: PropTypes.func,
}

const AboutPage = ({ data }) => {
const { markdownRemark: post } = data

return (
Expand All @@ -34,6 +41,12 @@ export default ({ data }) => {
)
}

AboutPage.propTypes = {
data: PropTypes.object.isRequired,
}

export default AboutPage

export const aboutPageQuery = graphql`
query AboutPage($id: String!) {
markdownRemark(id: { eq: $id }) {
Expand Down
Loading

0 comments on commit 3dbd434

Please sign in to comment.