diff --git a/gatsby-node.js b/gatsby-node.js index 3825867..18ff959 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -119,7 +119,7 @@ exports.onCreateNode = async function ({ node, getNode, actions }) { const iptcData = iptc(file); const exifData = await read(parent.absolutePath); const vibrantData = await Vibrant.from(parent.absolutePath) - .quality(1) + .quality(2) .getPalette(); createNodeField({ @@ -156,15 +156,24 @@ exports.createPages = async ({ graphql, actions, reporter }) => { } // Create pages for each markdown file. const galleryImageTemplate = path.resolve('src/components/GalleryImage.js'); - galleryImages.data.allFile.edges.forEach(({ node }) => { - // const path = node.base + const edges = galleryImages.data.allFile.edges; + + edges.forEach(({ node }, index) => { + const nextImage = index === edges.length - 1 + ? null + : edges[index + 1].node.base; + const prevImage = index === 0 + ? null + : edges[index - 1].node.base; + console.log('next', nextImage); + createPage({ path: `photogallery/${node.base}`, component: galleryImageTemplate, - // In your blog post template's graphql query, you can use pagePath - // as a GraphQL variable to query for data from the markdown file. context: { imageFilename: node.base, + nextImage, + prevImage, }, }); }); diff --git a/src/components/GalleryImage.js b/src/components/GalleryImage.js index 38dbe34..eb064cd 100644 --- a/src/components/GalleryImage.js +++ b/src/components/GalleryImage.js @@ -1,5 +1,5 @@ import React from 'react'; -import { graphql, Link, navigate } from 'gatsby'; +import { graphql, navigate, Link } from 'gatsby'; import { getAspectRatio, getMeta, @@ -13,11 +13,11 @@ import { GatsbyImage, getImage } from 'gatsby-plugin-image'; import { Helmet } from 'react-helmet'; import classnames from 'classnames'; -const GalleryImage = ({ data }) => { +const GalleryImage = ({ data, pageContext }) => { const image = data.allFile.edges[0].node; const ar = getAspectRatio(image); - // TODO: metadata icons + console.log(pageContext); const name = getName(image); const meta = getMeta(image); @@ -39,12 +39,30 @@ const GalleryImage = ({ data }) => { style={getVibrantToHelmetSafeBodyStyle(vibrant)} /> - -
+ +
{ className={classnames( 'hover:underline inline-block p-3 px-5 my-3 text-lg rounded-md border-2 arrow-right-after font-bold font-serif', isClient && 'text-muted-dark bg-muted-light hover:border-muted border-muted-dark')} - to="/photogallery" + to="/photogallery/" > Photography Gallery diff --git a/src/pages/photogallery.js b/src/pages/photogallery.js index fe2191d..0dce853 100644 --- a/src/pages/photogallery.js +++ b/src/pages/photogallery.js @@ -1,5 +1,5 @@ import * as React from 'react'; -import { graphql } from 'gatsby'; +import { graphql, Link } from 'gatsby'; import { navigate } from 'gatsby'; import { Helmet } from 'react-helmet'; @@ -19,13 +19,23 @@ const GalleryPage = ({ data }) => { Photo Gallery | Chuck Dries -
+ +
+

Photo Gallery