1.1.0 • Published 4 years ago

gatsby-source-saphy v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

gatsby-source-saphy

use saphy strore as a source to your gatsbyjs ecommerce website

Installation

    #NPM
    npm i --save gatsby-source-saphy
    #YARN
    yarn add gatsby-source-saphy

add the envirenment variable SAPHY_KEY=...

use in gatsby-config.js

    plugins: [
        //...
        {
            resolve:'gatsby-source-saphy',
            options:{
                SAPHY_KEY:"..."
            }
        }
    ]
    

query all product from your store using GraphQL

   exports.createPages = async ({ graphql, actions }) => {

    const { createPage } = actions;
    const postTempalte = path.resolve("./src/templates/post.js");

    return graphql(`
    query {
        allSaphy {
            edges {
              node {
                avatar
                name
                id
              }
            }
        }
    }
  `).then(result => {

        let alledges = result.data.allSaphy.edges
        alledges.forEach(({ node }) => {
            createPage({
                path: _.kebabCase(node.name),
                id: node.id,
                component: postTempalte,
                context: {
                    id: node.id
                }
            })
        })
    })

}
1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago