Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add media library support #14

Merged
merged 2 commits into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 6 additions & 60 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,12 @@ exports.createPages = ({ boundActionCreators, graphql }) => {
path
date
title
image {
childImageSharp {
resolutions(width: 1400) {
width
height
src
srcSet
}
}
}
image
heading
description
intro {
blurbs {
image {
childImageSharp {
resolutions(width: 220) {
width
height
src
srcSet
}
}
}
image
text
}
heading
Expand All @@ -50,58 +32,22 @@ exports.createPages = ({ boundActionCreators, graphql }) => {
description
image1 {
alt
image {
childImageSharp {
resolutions(width: 400) {
width
height
src
srcSet
}
}
}
image
}
image2 {
alt
image {
childImageSharp {
resolutions(width: 400) {
width
height
src
srcSet
}
}
}
image
}
image3 {
alt
image {
childImageSharp {
resolutions(width: 400) {
width
height
src
srcSet
}
}
}
image
}
}
testimonials {
author
quote
}
full_image {
childImageSharp {
resolutions(width: 400) {
width
height
src
srcSet
}
}
}
full_image
pricing {
heading
description
Expand Down
4 changes: 2 additions & 2 deletions src/components/Features.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import React from 'react';
const FeatureGrid = ({ gridItems }) => (
<div className="columns is-multiline">
{gridItems.map(item => (
<div key={item.image.childImageSharp.resolutions.src} className="column is-6">
<div key={item.image} className="column is-6">
<section className="section">
<p className="has-text-centered">
<img alt="" src={item.image.childImageSharp.resolutions.src} />
<img alt="" src={item.image} />
</p>
<p>{item.text}</p>
</section>
Expand Down
18 changes: 9 additions & 9 deletions src/pages/product/product.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
templateKey: 'product-page'
path: /products
title: Our Coffee
image: ./img/products/jumbotron.jpg
image: /img/jumbotron.jpg
heading: What we offer
description: >-
Kaldi is the ultimate spot for coffee lovers who want to learn about their
Expand All @@ -11,27 +11,27 @@ description: >-
anyone.
intro:
blurbs:
- image: ./img/illustrations/coffee.png
- image: /img/coffee.png
text: >
We sell green and roasted coffee beans that are sourced directly from
independent farmers and farm cooperatives. We’re proud to offer a
variety of coffee beans grown with great care for the environment and
local communities. Check our post or contact us directly for current
availability.
- image: ./img/illustrations/coffee-gear.png
- image: /img/coffee-gear.png
text: >
We offer a small, but carefully curated selection of brewing gear and
tools for every taste and experience level. No matter if you roast your
own beans or just bought your first french press, you’ll find a gadget
to fall in love with in our shop.
- image: ./img/illustrations/tutorials.png
- image: /img/tutorials.png
text: >
Love a great cup of coffee, but never knew how to make one? Bought a
fancy new Chemex but have no clue how to use it? Don't worry, we’re here
to help. You can schedule a custom 1-on-1 consultation with our baristas
to learn anything you want to know about coffee roasting and brewing.
Email us or call the store for details.
- image: ./img/illustrations/meeting-space.png
- image: /img/meeting-space.png
text: >
We believe that good coffee has the power to bring people together.
That’s why we decided to turn a corner of our shop into a cozy meeting
Expand All @@ -53,13 +53,13 @@ main:
optimal for the plants, farmers and the local environment.
image1:
alt: A close-up of a paper filter filled with ground coffee
image: ./img/products/products-grid3.jpg
image: /img/products-grid3.jpg
image2:
alt: A green cup of a coffee on a wooden table
image: ./img/products/products-grid2.jpg
image: /img/products-grid2.jpg
image3:
alt: Coffee beans
image: ./img/products/products-grid1.jpg
image: /img/products-grid1.jpg
testimonials:
- author: Elisabeth Kaurismäki
quote: >-
Expand All @@ -69,7 +69,7 @@ testimonials:
quote: >-
Kaldi is the place to go if you want the best quality coffee. I love their
stance on empowering farmers and transparency.
full_image: ./img/products/products-full-width.jpg
full_image: /img/products-full-width.jpg
pricing:
heading: Monthly subscriptions
description: >-
Expand Down
68 changes: 11 additions & 57 deletions src/templates/product-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import React from 'react';
import Features from '../components/Features';
import Testimonials from '../components/Testimonials';
import Pricing from '../components/Pricing';
import grid1 from '../pages/product/img/products/products-grid1.jpg';
import grid2 from '../pages/product/img/products/products-grid2.jpg';
import grid3 from '../pages/product/img/products/products-grid3.jpg';
import fullWidth from '../pages/product/img/products/products-full-width.jpg';

export default ({ data }) => {
console.log(data);
Expand All @@ -19,7 +15,7 @@ export default ({ data }) => {
<div className="content">
<div
className="full-width-image-container margin-top-0"
style={{ backgroundImage: `url(${frontmatter.image.childImageSharp.resolutions.src})` }}
style={{ backgroundImage: `url(${frontmatter.image})` }}
>
<h2
className="has-text-weight-bold is-size-1"
Expand Down Expand Up @@ -53,7 +49,7 @@ export default ({ data }) => {
<article className="tile is-child">
<img
style={{ borderRadius: '5px' }}
src={frontmatter.main.image1.image.childImageSharp.resolutions.src}
src={frontmatter.main.image1.image}
alt=""
/>
</article>
Expand All @@ -62,7 +58,7 @@ export default ({ data }) => {
<article className="tile is-child">
<img
style={{ borderRadius: '5px' }}
src={frontmatter.main.image2.image.childImageSharp.resolutions.src}
src={frontmatter.main.image2.image}
alt=""
/>
</article>
Expand All @@ -72,7 +68,7 @@ export default ({ data }) => {
<article className="tile is-child">
<img
style={{ borderRadius: '5px' }}
src={frontmatter.main.image3.image.childImageSharp.resolutions.src}
src={frontmatter.main.image3.image}
alt=""
/>
</article>
Expand All @@ -82,7 +78,7 @@ export default ({ data }) => {
<Testimonials testimonials={frontmatter.testimonials} />
<div
className="full-width-image-container"
style={{ backgroundImage: `url(${frontmatter.full_image.childImageSharp.resolutions.src})` }}
style={{ backgroundImage: `url(${frontmatter.full_image})` }}
/>
<h2 className="has-text-weight-semibold is-size-2">{frontmatter.pricing.heading}</h2>
<p className="is-size-5">{frontmatter.pricing.description}</p>
Expand All @@ -102,30 +98,12 @@ export const productPageQuery = graphql`
frontmatter {
title
path
image {
childImageSharp {
resolutions(width: 1400) {
width
height
src
srcSet
}
}
}
image
heading
description
intro {
blurbs {
image {
childImageSharp {
resolutions(width: 220) {
width
height
src
srcSet
}
}
}
image
text
}
heading
Expand All @@ -136,46 +114,22 @@ export const productPageQuery = graphql`
description
image1 {
alt
image {
childImageSharp {
resolutions(width: 700) {
src
}
}
}
image
}
image2 {
alt
image {
childImageSharp {
resolutions(width: 700) {
src
}
}
}
image
}
image3 {
alt
image {
childImageSharp {
resolutions(width: 1400) {
src
}
}
}
image
}
}
testimonials {
author
quote
}
full_image {
childImageSharp {
resolutions(width: 1400) {
src
}
}
}
full_image
pricing {
heading
description
Expand Down
5 changes: 3 additions & 2 deletions static/admin/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ backend:
name: git-gateway
branch: master

media_folder: "/src/pages/blog/img"
public_folder: "img"
media_folder: static/img
public_folder: img

collections:
- name: "blog"
Expand Down Expand Up @@ -34,6 +34,7 @@ collections:
name: "products"
fields:
- {label: "Template Key", name: "templateKey", widget: "hidden", default: "product-page"}
- {label: "Path", name: "path", widget: "hidden", default: "/products"}
- {label: Title, name: title, widget: string}
- {label: Image, name: image, widget: image}
- {label: Heading, name: heading, widget: string}
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes