This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Build pages for all catalogue data (#9)
* refactor: useStaticQuery hook * feat: Build category pages * feat: Build collection pages * feat: Build brands pages * chore: yarn.lock * chore: Bump to latest @moltin/gatsby-source-moltin * refactor: Use path field for page patg when building pages * fix: add resolvers for nodes that require path
- Loading branch information
Showing
7 changed files
with
527 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
import React from 'react' | ||
import { graphql } from 'gatsby' | ||
import { graphql, useStaticQuery } from 'gatsby' | ||
|
||
import ProductGrid from '../components/ProductGrid' | ||
|
||
const IndexPage = ({ data: { products } }) => ( | ||
<ProductGrid products={products.edges.map(({ node: product }) => product)} /> | ||
) | ||
|
||
export const query = graphql` | ||
query { | ||
products: allMoltinProduct { | ||
edges { | ||
node { | ||
id | ||
name | ||
slug | ||
path | ||
const IndexPage = () => { | ||
const { products } = useStaticQuery(graphql` | ||
query { | ||
products: allMoltinProduct { | ||
edges { | ||
node { | ||
id | ||
name | ||
slug | ||
path | ||
} | ||
} | ||
} | ||
} | ||
} | ||
` | ||
`) | ||
|
||
return ( | ||
<ProductGrid | ||
products={products.edges.map(({ node: product }) => product)} | ||
/> | ||
) | ||
} | ||
|
||
export default IndexPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
import { graphql } from 'gatsby' | ||
|
||
const BrandPage = ({ data: { brand } }) => ( | ||
<React.Fragment> | ||
<h1>{brand.name}</h1> | ||
<p>{brand.description}</p> | ||
</React.Fragment> | ||
) | ||
|
||
export const query = graphql` | ||
query($id: String!) { | ||
brand: moltinBrand(id: { eq: $id }) { | ||
id | ||
name | ||
description | ||
} | ||
} | ||
` | ||
|
||
export default BrandPage |
21 changes: 21 additions & 0 deletions
21
packages/gatsby-theme-moltin/src/templates/CategoryPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
import { graphql } from 'gatsby' | ||
|
||
const CategoryPage = ({ data: { category } }) => ( | ||
<React.Fragment> | ||
<h1>{category.name}</h1> | ||
<p>{category.description}</p> | ||
</React.Fragment> | ||
) | ||
|
||
export const query = graphql` | ||
query($id: String!) { | ||
category: moltinCategory(id: { eq: $id }) { | ||
id | ||
name | ||
description | ||
} | ||
} | ||
` | ||
|
||
export default CategoryPage |
21 changes: 21 additions & 0 deletions
21
packages/gatsby-theme-moltin/src/templates/CollectionPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
import { graphql } from 'gatsby' | ||
|
||
const CollectionPage = ({ data: { collection } }) => ( | ||
<React.Fragment> | ||
<h1>{collection.name}</h1> | ||
<p>{collection.description}</p> | ||
</React.Fragment> | ||
) | ||
|
||
export const query = graphql` | ||
query($id: String!) { | ||
collection: moltinCollection(id: { eq: $id }) { | ||
id | ||
name | ||
description | ||
} | ||
} | ||
` | ||
|
||
export default CollectionPage |
Oops, something went wrong.
29639ea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully aliased the URL https://gatsby-theme-moltin-4sdbhxrpt.now.sh to the following aliases.