Skip to content

Commit f3cba6e

Browse files
authored
Merge pull request #16 from GatsbyStorefront/v4
4.0.0-beta4
2 parents 08522f5 + fd1c49f commit f3cba6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2242
-1597
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ public/
1010
yarn.lock
1111
.env
1212
yarn-error.log
13+
~*

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
public
22
.cache
33
node_modules
4-
yarn-error.log
4+
yarn-error.log
5+
~*

README.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ And if you like Gatsby Storefront **please give us a star on GitHub** ⭐ 👍
2424
- [Create `.env` file](#create-env-file)
2525
- [Enable theme](#enable-theme)
2626
- [Shopify content requirement](#shopify-content-requirement)
27-
- [A setup for Shopify Lite plan](#a-setup-for-shopify-lite-plan)
2827
- [Starter](#starter)
2928
- [Configuration](#configuration)
3029
- [Configuration file](#configuration-file)
@@ -90,10 +89,17 @@ npm install @gatsbystorefront/gatsby-theme-storefront-shopify
9089
Create `.env` file in your store's root directory with your Shopify storename (**storename**.myshopify.com) and [access token](https://help.shopify.com/en/api/getting-started/authentication/private-authentication#generate-credentials-from-the-shopify-admin) (your token must have full permissions on Storefront API).
9190

9291
```
93-
GATSBY_SHOP_NAME=your_shopify_store_name
92+
GATSBY_SHOPIFY_SHOP_NAME=your_shopify_store_name
9493
GATSBY_SHOPIFY_ACCESS_TOKEN=your_shopify_access_token
9594
```
9695

96+
In case you are using Gatsby Storefront API to enable connections with external data sources (Contentful, Yotpo), please add additional configuration variables to your `.env` file:
97+
98+
```
99+
GATSBYSTOREFRONT_API_URL=your_api_url.gatsbystorefront.com
100+
GATSBYSTOREFRONT_ACCESS_TOKEN=your_gatsbystorefrontApi_access_token
101+
```
102+
97103
### Enable theme
98104

99105
Enable `gatsbystorefront/gatsby-theme-storefront-shopify` plugin in your `gatsby-config.js`:
@@ -107,17 +113,24 @@ module.exports = {
107113
{
108114
resolve: '@gatsbystorefront/gatsby-theme-storefront-shopify',
109115
options: {
110-
shopName: process.env.GATSBY_SHOP_NAME,
111-
accessToken: process.env.GATSBY_SHOPIFY_ACCESS_TOKEN,
116+
shopify: {
117+
shopName: process.env.GATSBY_SHOPIFY_SHOP_NAME,
118+
accessToken: process.env.GATSBY_SHOPIFY_ACCESS_TOKEN,
119+
},
120+
gatsbyStorefrontApi: {
121+
apiUrl: process.env.GATSBYSTOREFRONT_API_URL,
122+
accessToken: process.env.GATSBYSTOREFRONT_ACCESS_TOKEN,
123+
},
124+
useGatsbyStorefrontApi: false, // Set to 'true' in case you are using Gatsby Storefront API to enable connections with external data sources
112125
basePath: '/',
113-
shopifyLite: false, // default 'false'
114-
enableWebp: true, // default 'true'
115-
imageQuality: '95', // default '95', better to decrease but always check your result images quality
116-
gatsbyImageProps: { // See: https://www.gatsbyjs.com/plugins/gatsby-image/#gatsby-image-props
117-
loading: 'eager', // Using 'eager' currently improves Lighthouse 6 metrics. See: https://github.com/gatsbyjs/gatsby/issues/24332#issuecomment-650760081
118-
fadeIn: false,
119-
durationFadeIn: 500,
120-
}
126+
productImagesCarouselProps: {
127+
// See: https://github.com/express-labs/pure-react-carousel#carouselprovider-
128+
naturalSlideWidth: 500,
129+
naturalSlideHeight: 500,
130+
},
131+
product: {
132+
maxDescriptionSectionsNumber: 10,
133+
},
121134
manifest: { // web app manifest options to be passed to 'gatsby-plugin-manifest' installed inside theme
122135
name: 'Gatsby Storefront Demo Store',
123136
short_name: 'Gatsby Storefront',
@@ -147,11 +160,7 @@ module.exports = {
147160
148161
### Shopify content requirement
149162
150-
Please make sure that your Shopify web store has at least one [Collection](https://help.shopify.com/en/manual/products/collections), one [Product](https://help.shopify.com/en/manual/products/add-update-products) (associated with Collection), [Blog post](https://help.shopify.com/en/manual/sell-online/online-store/blogs/writing-blogs), [Page](https://help.shopify.com/en/manual/sell-online/online-store/pages) and [store Policies](https://help.shopify.com/en/manual/checkout-settings/refund-privacy-tos) added before runing your Gatsby Storefront, as it is neccesary for correct API exposure.
151-
152-
### A setup for Shopify Lite plan
153-
154-
If you are using Shopify Lite plan. Please set `shopifyLite` property to `true` in `@gatsbystorefront/gatsby-theme-storefront-shopify` plugin `options` in `gatsby-config.js`. This will disable generation of pages for Blog and Pages as they are not avalible in "Lite" plan.
163+
Please make sure that your Shopify web store has at least one [Collection](https://help.shopify.com/en/manual/products/collections), one [Product](https://help.shopify.com/en/manual/products/add-update-products) (associated with Collection) and [store Policies](https://help.shopify.com/en/manual/checkout-settings/refund-privacy-tos) added before runing your Gatsby Storefront, as it is neccesary for correct API exposure.
155164
156165
### Starter
157166

gatsby-config.js

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
1-
module.exports = ({
2-
shopName,
3-
accessToken,
4-
shopifyLite = false,
5-
imageQuality = '95',
1+
const path = require('path');
2+
3+
const config = ({
4+
shopify = {},
5+
gatsbyStorefrontApi = {},
6+
useGatsbyStorefrontApi = false,
67
manifest = {},
7-
gatsbyImageProps = {},
8-
}) => ({
9-
plugins: [
8+
productImagesCarouselProps = {},
9+
reviews = {},
10+
}) => {
11+
const plugins = [
1012
{
11-
resolve: 'gatsby-source-shopify',
13+
resolve: '@gatsbystorefront/gatsby-source-shopify',
1214
options: {
13-
shopName,
14-
accessToken,
15+
shopName:
16+
useGatsbyStorefrontApi &&
17+
gatsbyStorefrontApi.hasOwnProperty('apiUrl') &&
18+
gatsbyStorefrontApi.apiUrl
19+
? gatsbyStorefrontApi.apiUrl
20+
: shopify.shopName,
21+
accessToken:
22+
useGatsbyStorefrontApi &&
23+
gatsbyStorefrontApi.hasOwnProperty('accessToken') &&
24+
gatsbyStorefrontApi.accessToken
25+
? gatsbyStorefrontApi.accessToken
26+
: shopify.accessToken,
27+
useGatsbyStorefrontApi,
28+
includeCollections: ['shop'],
1529
},
1630
},
1731
{
@@ -30,14 +44,7 @@ module.exports = ({
3044
},
3145
},
3246
'gatsby-plugin-react-helmet',
33-
{
34-
resolve: `gatsby-plugin-sharp`,
35-
options: {
36-
useMozJpeg: false,
37-
stripMetadata: true,
38-
defaultQuality: imageQuality,
39-
},
40-
},
47+
'gatsby-plugin-sharp',
4148
'gatsby-transformer-sharp',
4249
'gatsby-plugin-theme-ui',
4350
'gatsby-plugin-sitemap',
@@ -93,8 +100,9 @@ module.exports = ({
93100
},
94101
},
95102
'gatsby-plugin-loadable-components-ssr',
96-
],
97-
siteMetadata: {
103+
];
104+
105+
const siteMetadata = {
98106
siteUrl: 'https://demo.gatsbystorefront.com',
99107
gatsbyStorefrontConfig: {
100108
storeName: 'Gatsby Storefront',
@@ -112,8 +120,10 @@ module.exports = ({
112120
// For available socia share buttons see: https://github.com/nygardk/react-share
113121
shareButtons: [],
114122
googleAnalyticsId: 'UA-141525658-3',
115-
isShopifyLite: shopifyLite,
116-
gatsbyImageProps: { ...gatsbyImageProps },
123+
productImagesCarouselProps: { ...productImagesCarouselProps },
124+
reviewsNumberPerPage: reviews.hasOwnProperty('reviewsNumberPerPage')
125+
? reviews.reviewsNumberPerPage
126+
: 10,
117127
//
118128
// Main page types: "carousel", "collection", "product"
119129
//
@@ -126,5 +136,12 @@ module.exports = ({
126136
productsPerCollectionPage: '9',
127137
articlesPerBlogPage: '6',
128138
},
129-
},
130-
});
139+
};
140+
141+
return {
142+
plugins,
143+
siteMetadata,
144+
};
145+
};
146+
147+
module.exports = config;

0 commit comments

Comments
 (0)