Fix merge

This commit is contained in:
Tobias Lins 2023-05-10 10:29:53 +02:00
commit 7f7f153c4c
6 changed files with 488 additions and 398 deletions

View File

@ -17,6 +17,10 @@ A Next.js 13 and App Router-ready ecommerce template, built with Shopify, featur
- Checkout and payments with Shopify - Checkout and payments with Shopify
- Automatic light/dark mode based on system settings - Automatic light/dark mode based on system settings
## Alternate Providers
- [Saleor](https://github.com/saleor/nextjs-commerce) ([Demo](https://saleor-commerce.vercel.app/))
## Running locally ## Running locally
You will need to use the environment variables [defined in `.env.example`](.env.example) to run Next.js Commerce. It's recommended you use [Vercel Environment Variables](https://vercel.com/docs/concepts/projects/environment-variables) for this, but a `.env` file is all that is necessary. You will need to use the environment variables [defined in `.env.example`](.env.example) to run Next.js Commerce. It's recommended you use [Vercel Environment Variables](https://vercel.com/docs/concepts/projects/environment-variables) for this, but a `.env` file is all that is necessary.
@ -36,6 +40,8 @@ Your app should now be running on [localhost:3000](http://localhost:3000/).
## How to configure your Shopify store for Next.js Commerce ## How to configure your Shopify store for Next.js Commerce
Next.js Commerce requires a [paid Shopify plan](https://www.shopify.com/pricing). It will not work with a Shopify Starter plan.
### Add Shopify domain to an environment variable ### Add Shopify domain to an environment variable
Create a `SHOPIFY_STORE_DOMAIN` environment variable and use your Shopify domain as the the value (ie. `SHOPIFY_STORE_SUBDOMAIN.myshopify.com`). Create a `SHOPIFY_STORE_DOMAIN` environment variable and use your Shopify domain as the the value (ie. `SHOPIFY_STORE_SUBDOMAIN.myshopify.com`).

View File

@ -6,28 +6,35 @@ const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
: 'http://localhost:3000'; : 'http://localhost:3000';
export default async function sitemap(): Promise<Promise<Promise<MetadataRoute.Sitemap>>> { export default async function sitemap(): Promise<Promise<Promise<MetadataRoute.Sitemap>>> {
const routesMap = ['', '/search'].map((route) => ({ const routesMap = [''].map((route) => ({
url: `${baseUrl}${route}`, url: `${baseUrl}${route}`,
lastModified: new Date().toISOString() lastModified: new Date().toISOString()
})); }));
const collections = await getCollections(); const collectionsPromise = getCollections().then((collections) =>
const collectionsMap = collections.map((collection) => ({ collections.map((collection) => ({
url: `${baseUrl}${collection.path}`, url: `${baseUrl}${collection.path}`,
lastModified: collection.updatedAt lastModified: collection.updatedAt
})); }))
);
const products = await getProducts({}); const productsPromise = getProducts({}).then((products) =>
const productsMap = products.map((product) => ({ products.map((product) => ({
url: `${baseUrl}/product/${product.handle}`, url: `${baseUrl}/product/${product.handle}`,
lastModified: product.updatedAt lastModified: product.updatedAt
})); }))
);
const pages = await getPages(); const pagesPromise = getPages().then((pages) =>
const pagesMap = pages.map((page) => ({ pages.map((page) => ({
url: `${baseUrl}/${page.handle}`, url: `${baseUrl}/${page.handle}`,
lastModified: page.updatedAt lastModified: page.updatedAt
})); }))
);
return [...routesMap, ...collectionsMap, ...productsMap, ...pagesMap]; const fetchedRoutes = (
await Promise.all([collectionsPromise, productsPromise, pagesPromise])
).flat();
return [...routesMap, ...fetchedRoutes];
} }

View File

@ -1,4 +1,6 @@
export const createUrl = (pathname: string, params: URLSearchParams) => { import { ReadonlyURLSearchParams } from 'next/navigation';
export const createUrl = (pathname: string, params: URLSearchParams | ReadonlyURLSearchParams) => {
const paramsString = params.toString(); const paramsString = params.toString();
const queryString = `${paramsString.length ? '?' : ''}${paramsString}`; const queryString = `${paramsString.length ? '?' : ''}${paramsString}`;

View File

@ -4,9 +4,6 @@ module.exports = {
// Disabling on production builds because we're running checks on PRs via GitHub Actions. // Disabling on production builds because we're running checks on PRs via GitHub Actions.
ignoreDuringBuilds: true ignoreDuringBuilds: true
}, },
experimental: {
appDir: true
},
images: { images: {
formats: ['image/avif', 'image/webp'], formats: ['image/avif', 'image/webp'],
remotePatterns: [ remotePatterns: [

View File

@ -22,34 +22,34 @@
"*": "prettier --write --ignore-unknown" "*": "prettier --write --ignore-unknown"
}, },
"dependencies": { "dependencies": {
"@headlessui/react": "^1.7.10", "@headlessui/react": "^1.7.14",
"@vercel/analytics": "^1.0.0", "@vercel/analytics": "^1.0.0",
"@vercel/og": "^0.1.0", "@vercel/og": "^0.5.4",
"clsx": "^1.2.1", "clsx": "^1.2.1",
"framer-motion": "^8.4.0", "framer-motion": "^10.12.8",
"is-empty-iterable": "^3.0.0", "is-empty-iterable": "^3.0.0",
"next": "13.3.1", "next": "13.4.1",
"react": "18.2.0", "react": "18.2.0",
"react-cookie": "^4.1.1", "react-cookie": "^4.1.1",
"react-dom": "18.2.0" "react-dom": "18.2.0"
}, },
"devDependencies": { "devDependencies": {
"@playwright/test": "^1.31.2", "@playwright/test": "^1.33.0",
"@tailwindcss/typography": "^0.5.9", "@tailwindcss/typography": "^0.5.9",
"@types/node": "18.13.0", "@types/node": "20.1.0",
"@types/react": "18.0.27", "@types/react": "18.2.6",
"@types/react-dom": "18.0.10", "@types/react-dom": "18.2.4",
"@vercel/git-hooks": "^1.0.0", "@vercel/git-hooks": "^1.0.0",
"autoprefixer": "^10.4.13", "autoprefixer": "^10.4.14",
"eslint": "^8.35.0", "eslint": "^8.40.0",
"eslint-config-next": "^13.3.1", "eslint-config-next": "^13.4.1",
"eslint-config-prettier": "^8.6.0", "eslint-config-prettier": "^8.8.0",
"eslint-plugin-unicorn": "^45.0.2", "eslint-plugin-unicorn": "^47.0.0",
"lint-staged": "^13.1.1", "lint-staged": "^13.2.2",
"postcss": "^8.4.21", "postcss": "^8.4.23",
"prettier": "^2.8.4", "prettier": "^2.8.8",
"prettier-plugin-tailwindcss": "^0.2.2", "prettier-plugin-tailwindcss": "^0.2.8",
"tailwindcss": "^3.2.6", "tailwindcss": "^3.3.2",
"typescript": "4.9.5" "typescript": "5.0.4"
} }
} }

794
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff