Skip to content

Commit c6fee88

Browse files
authored
Merge pull request #829 from w3bdesign/develop
Replace nextConfig with .env variables
2 parents 1685190 + 27ae953 commit c6fee88

File tree

11 files changed

+39
-71
lines changed

11 files changed

+39
-71
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
NEXT_PUBLIC_GRAPHQL_URL="https://wordpress.url.com/graphql"
2+
NEXT_PUBLIC_ALGOLIA_INDEX_NAME= "algolia"
3+
NEXT_PUBLIC_PLACEHOLDER_SMALL_IMAGE_URL="https://res.cloudinary.com/placeholder-337_utsb7h.jpg"
4+
NEXT_PUBLIC_PLACEHOLDER_LARGE_IMAGE_URL="https://res.cloudinary.com/placeholder-616-616_beecp5.jpg"
5+
NEXT_PUBLIC_ALGOLIA_APP_ID = "changeme"
6+
NEXT_PUBLIC_ALGOLIA_PUBLIC_API_KEY = "changeme"
17
NODE_ENV="development"

.env.local.example

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,18 @@ The current release has been tested and is confirmed working with the following
4141

4242
https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/ (Firefox)
4343

44-
https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm (Chrome)
45-
46-
Rename .env.example to .env so the Apollo debugger will correctly load. It will not load if the NODE_ENV variable is not correctly set.
44+
https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm (Chrome)
45+
4746

4847
3. Make sure WooCommerce has some products already or import some sample products
4948

5049
The WooCommerce sample products CSV file is available at `wp-content/plugins/woocommerce/sample-data/sample_products.csv` or [Sample products](sample_products/)
5150

5251
Import the products at `WP Dashboard > Tools > Import > WooCommerce products(CSV)`
5352

54-
4. Clone or fork the repo and modify `nextConfig.js`.
53+
4. Clone or fork the repo and modify `.env.example` and rename it to `.env.`
5554

56-
Then set the environment variables ALGOLIA_APP_ID and ALGOLIA_PUBLIC_API_KEY in Vercel or your preferred hosting solution.
55+
Then set the environment variables accordingly in Vercel or your preferred hosting solution.
5756

5857
See https://vercel.com/docs/environment-variables
5958

components/AlgoliaSearch/AlgoliaSearchBox.component.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import algoliasearch from 'algoliasearch';
22
import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom';
33
import { useState } from 'react';
44

5-
import WOO_CONFIG from 'utils/config/nextConfig';
65
import SearchResults from './SearchResults.component';
76

87
const searchClient = algoliasearch(
@@ -23,7 +22,7 @@ const AlgoliaSearchBox = () => {
2322
<div className="hidden mt-2 md:inline xl:inline">
2423
<div className="">
2524
<InstantSearch
26-
indexName={WOO_CONFIG.ALGOLIA_INDEX_NAME}
25+
indexName={process.env.NEXT_PUBLIC_ALGOLIA_INDEX_NAME}
2726
searchClient={searchClient}
2827
>
2928
{/*We need to conditionally add a border because the element has position:fixed*/}

components/AlgoliaSearch/MobileSearch.component.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import algoliasearch from 'algoliasearch';
22
import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom';
33
import { useState } from 'react';
44

5-
import WOO_CONFIG from 'utils/config/nextConfig';
65
import SearchResults from './SearchResults.component';
76

87
const searchClient = algoliasearch(
@@ -19,7 +18,7 @@ const MobileSearch = () => {
1918
return (
2019
<div className="inline mt-4">
2120
<InstantSearch
22-
indexName={WOO_CONFIG.ALGOLIA_INDEX_NAME}
21+
indexName={process.env.NEXT_PUBLIC_ALGOLIA_INDEX_NAME}
2322
searchClient={searchClient}
2423
>
2524
<SearchBox

components/Product/IndexProducts.component.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import Link from 'next/link';
22
import { v4 as uuidv4 } from 'uuid';
33

4-
import WOO_CONFIG from 'utils/config/nextConfig';
5-
64
import { filteredVariantPrice } from 'utils/functions/functions';
75

86
/**
@@ -45,7 +43,7 @@ const IndexProducts = ({ products }) => (
4543
id="product-image"
4644
className="transition duration-500 ease-in-out transform cursor-pointer hover:grow hover:shadow-lg hover:scale-105"
4745
alt={name}
48-
src={WOO_CONFIG.PLACEHOLDER_SMALL_IMAGE_URL}
46+
src={process.env.NEXT_PUBLIC_PLACEHOLDER_SMALL_IMAGE_URL}
4947
/>
5048
)}
5149
</a>

components/Product/SingleProduct.component.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { useState, useEffect } from 'react';
33
import AddToCartButton from 'components/Cart/AddToCartButton.component';
44
import LoadingSpinner from 'components/LoadingSpinner/LoadingSpinner.component';
55

6-
import WOO_CONFIG from 'utils/config/nextConfig';
7-
86
import { filteredVariantPrice } from 'utils/functions/functions';
97

108
/**
@@ -55,7 +53,7 @@ const SingleProduct = ({ product }) => {
5553
id="product-image"
5654
className="h-auto p-8 transition duration-500 ease-in-out transform xl:p-2 md:p-2 lg:p-2 hover:grow hover:shadow-lg hover:scale-105"
5755
alt={name}
58-
src={WOO_CONFIG.PLACEHOLDER_LARGE_IMAGE_URL}
56+
src={process.env.NEXT_PUBLIC_PLACEHOLDER_LARGE_IMAGE_URL}
5957
/>
6058
)}
6159
<div className="ml-8">

package-lock.json

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

utils/apollo/ApolloClient.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import {
77
ApolloLink,
88
} from '@apollo/client';
99

10-
import WOO_CONFIG from 'utils/config/nextConfig';
11-
1210
/**
1311
* Middleware operation
1412
* If we have a session token in localStorage, add it to the GraphQL request as a Session header.
@@ -79,7 +77,7 @@ const client = new ApolloClient({
7977
link: middleware.concat(
8078
afterware.concat(
8179
createHttpLink({
82-
uri: WOO_CONFIG.GRAPHQL_URL,
80+
uri: process.env.NEXT_PUBLIC_GRAPHQL_URL,
8381
fetch,
8482
})
8583
)

utils/config/nextConfig.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)