@graphcommerce/docs 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +4 -0
- package/CHANGELOG.md +160 -0
- package/components/Layout/LayoutFull.tsx +85 -0
- package/components/Layout/Logo.tsx +19 -0
- package/components/Layout/graphcommerce.svg +34 -0
- package/components/Search.tsx +37 -0
- package/components/SearchForm.tsx +110 -0
- package/components/SidebarMenu/index.tsx +101 -0
- package/components/prism.css +274 -0
- package/components/rehype-prism-plus.css +49 -0
- package/components/theme.ts +410 -0
- package/content/framework/deployment.md +56 -0
- package/content/framework/environment-variables.md +61 -0
- package/content/framework/favicon.md +38 -0
- package/content/framework/graphcms.md +66 -0
- package/content/framework/icons.md +255 -0
- package/content/framework/readme.md +79 -0
- package/content/framework/seo.md +64 -0
- package/content/framework/static-file-serving.md +44 -0
- package/content/framework/static-generation.md +221 -0
- package/content/framework/theming.md +258 -0
- package/content/framework/translations.md +112 -0
- package/content/framework/troubleshooting.md +67 -0
- package/content/framework/typography.md +143 -0
- package/content/getting-started/create.md +152 -0
- package/content/getting-started/graphcms-component.md +240 -0
- package/content/getting-started/header.md +224 -0
- package/content/getting-started/pages.md +290 -0
- package/content/getting-started/readme.md +294 -0
- package/content/getting-started/start-building.md +160 -0
- package/content/getting-started/vscode.md +48 -0
- package/content/readme.md +124 -0
- package/content/roadmap.md +31 -0
- package/lib/DocumentIndexer.ts +59 -0
- package/lib/files.ts +168 -0
- package/lib/instantSearch.ts +26 -0
- package/lib/typesense/IndexerHandler.ts +47 -0
- package/lib/typesense/Leaves.ts +37 -0
- package/lib/typesense/SearchIndexer.ts +64 -0
- package/lib/typesense/batchInterable.ts +13 -0
- package/lib/typesense/createInstantSearchProps.ts +36 -0
- package/lib/typesense/typesenseClientConf.ts +23 -0
- package/lib/typesense/typesenseIndexerHandler.ts +23 -0
- package/next-env.d.ts +5 -0
- package/next.config.js +21 -0
- package/package.json +56 -0
- package/pages/[[...url]].tsx +391 -0
- package/pages/_app.tsx +26 -0
- package/pages/_document.tsx +22 -0
- package/pages/api/reindex.ts +4 -0
- package/pages/menu/[[...url]].tsx +69 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/favicon.svg +12 -0
- package/public/link.svg +4 -0
- package/public/manifest/favicon-192.png +0 -0
- package/public/manifest/favicon-512.png +0 -0
- package/public/manifest.webmanifest +20 -0
- package/tsconfig.json +5 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
> **Developer preview**
|
|
2
|
+
> This is a developer preview of GraphCommerce. The documentation will be
|
|
3
|
+
> updated as GraphCommerce introduces
|
|
4
|
+
> [new features and refines existing functionality](https://github.com/ho-nl/m2-pwa/releases).
|
|
5
|
+
|
|
6
|
+
# Deploy a Graphcommerce app with Vercel
|
|
7
|
+
|
|
8
|
+
Congratulations, you are ready to deploy your GraphCommerce storefront to
|
|
9
|
+
production. The fastest way to deploy your GraphCommerce app is with
|
|
10
|
+
[Vercel ↗](https://vercel.com/).
|
|
11
|
+
|
|
12
|
+
Vercel allows for automatic deployments on every branch push and merges onto the
|
|
13
|
+
Production Branch of your GitHub project:
|
|
14
|
+
|
|
15
|
+
- Login to Vercel, click the "New Project" button
|
|
16
|
+
- Import your Git Repository. Use the search to type your project's name. If
|
|
17
|
+
it's not showing up, click the 'Configure Github App' to grant Vercel
|
|
18
|
+
repository access
|
|
19
|
+
|
|
20
|
+
<figure>
|
|
21
|
+
<img src="https://cdn-std.droplr.net/files/acc_857465/e62La4"/>
|
|
22
|
+
</figure>
|
|
23
|
+
|
|
24
|
+
- Set the Environment Variables from your .env file:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
GRAPHCMS_URL=""
|
|
28
|
+
MAGENTO_ENDPOINT=""
|
|
29
|
+
IMAGE_DOMAINS=""
|
|
30
|
+
NEXT_PUBLIC_LOCALE_STORES=""
|
|
31
|
+
NEXT_PUBLIC_DISPLAY_INCL_TAX=""
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- Vercel will auto assign a domain to your project. In this example, the Github
|
|
35
|
+
project repository name is `graphcommerce-example`, so the domain will be
|
|
36
|
+
`https://graphcommerce-example.vercel.app`. Add this domain as the GraphQL and
|
|
37
|
+
Public site URL Environment Variables:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
NEXT_PUBLIC_GRAPHQL_ENDPOINT="https://graphcommerce-example.vercel.app/api/graphql"
|
|
41
|
+
NEXT_PUBLIC_SITE_URL="https://graphcommerce-example.vercel.app/"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
<figure>
|
|
45
|
+
<img src="https://cdn-std.droplr.net/files/acc_857465/gkuuby"/>
|
|
46
|
+
</figure>
|
|
47
|
+
|
|
48
|
+
- Hit the "Deploy" button
|
|
49
|
+
- A custom domain can be configured in the Vercel Project Settings. Update the
|
|
50
|
+
`NEXT_PUBLIC_GRAPHQL_ENDPOINT` and `NEXT_PUBLIC_SITE_URL` variables
|
|
51
|
+
afterwards.
|
|
52
|
+
|
|
53
|
+
## Next steps
|
|
54
|
+
|
|
55
|
+
- Learn about [Static Generation (SSG)](../framework/static-generation.md) in
|
|
56
|
+
GraphCommerce
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
> **Developer preview**
|
|
2
|
+
> This is a developer preview of GraphCommerce. The documentation will be
|
|
3
|
+
> updated as GraphCommerce introduces
|
|
4
|
+
> [new features and refines existing functionality](https://github.com/ho-nl/m2-pwa/releases).
|
|
5
|
+
|
|
6
|
+
# Environment Variables
|
|
7
|
+
|
|
8
|
+
This guide describes how to store environment variables in your GraphCommerce
|
|
9
|
+
project.
|
|
10
|
+
|
|
11
|
+
## How environment variables work
|
|
12
|
+
|
|
13
|
+
You can store environment variables in the .env file in your GraphCommerce root
|
|
14
|
+
directory. Any variable from .env files that aren't prefixed with `NEXT_PUBLIC`
|
|
15
|
+
is treated as a server runtime variable. These variables are not exposed to the
|
|
16
|
+
browser.
|
|
17
|
+
|
|
18
|
+
Environment variables will be loaded into `process.env`, allowing you to use
|
|
19
|
+
them in Next.js data fetching methods and API routes:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
// /lib/graphql/GraphQLProvider.tsx
|
|
23
|
+
|
|
24
|
+
// ...
|
|
25
|
+
new HttpLink({
|
|
26
|
+
uri: process.env.NEXT_PUBLIC_GRAPHQL_ENDPOINT,
|
|
27
|
+
credentials: 'same-origin',
|
|
28
|
+
})
|
|
29
|
+
// ...
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Public variables
|
|
33
|
+
|
|
34
|
+
Expose environment variables to the browser by prefixing with `NEXT_PUBLIC`.
|
|
35
|
+
These variables can be accessed in any component:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Google TagManager ID
|
|
39
|
+
NEXT_PUBLIC_GTM_ID="GTM-000000"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
// /node_modules/@graphcommerce/googleanalytics/components/GoogleAnalyticsScript.tsx
|
|
44
|
+
|
|
45
|
+
export default function GoogleAnalyticsScript() {
|
|
46
|
+
const id = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS
|
|
47
|
+
|
|
48
|
+
...
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Deployment Environment Variables
|
|
53
|
+
|
|
54
|
+
When [deploying your GraphCommerce storefront](./deployment.md) to Vercel,
|
|
55
|
+
Environment Variables can be configured in the Project Settings.
|
|
56
|
+
|
|
57
|
+
## Next steps
|
|
58
|
+
|
|
59
|
+
- Learn how to [deploy your GraphCommerce storefront](./deployment.md) to Vercel
|
|
60
|
+
- Read more about
|
|
61
|
+
[Environment Variables in Next.js ↗](https://nextjs.org/docs/basic-features/environment-variables#loading-environment-variables)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Favicon
|
|
2
|
+
|
|
3
|
+
GraphCommerce offers a [magento-graphcms example](../getting-started/readme.md)
|
|
4
|
+
that provides an approachable path to building GraphCommerce custom e-commerce
|
|
5
|
+
storefront.
|
|
6
|
+
|
|
7
|
+
Included in the magento-graphcms example, is a
|
|
8
|
+
[well-founded implementation ↗](https://medium.com/web-dev-survey-from-kyoto/favicon-nightmare-how-to-maintain-sanity-7628bfc39918)
|
|
9
|
+
for a correct favicon and touch icon.
|
|
10
|
+
|
|
11
|
+
Favicons can be found in the /public directory:
|
|
12
|
+
|
|
13
|
+
```txt
|
|
14
|
+
/public/favicon.ico
|
|
15
|
+
/public/favicon.svg
|
|
16
|
+
/public/apple-touch-icon.png
|
|
17
|
+
/public/manifest/favicon-512.png
|
|
18
|
+
/public/manifest/favicon-192.png
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Replacing the favicon
|
|
22
|
+
|
|
23
|
+
To replace the favicon with your own, simply replace the image files located in
|
|
24
|
+
the /public and /public/manifest directories. Pay attention to the standardized
|
|
25
|
+
["minimum safe zone ↗"](https://web.dev/maskable-icon/?utm_source=devtools#are-my-current-icons-ready)
|
|
26
|
+
|
|
27
|
+
You can use the GraphCommerce
|
|
28
|
+
[favicon sketch template ↗](https://drive.google.com/file/d/1tKiU54TgLd_sbd0tArpaqYdD9VYiYwwt/view?usp=sharing)
|
|
29
|
+
to simplify the process of making correct favicons.
|
|
30
|
+
|
|
31
|
+
<figure>
|
|
32
|
+
<img src="https://cdn-std.droplr.net/files/acc_857465/8wbzEN" />
|
|
33
|
+
<figcaption>Favicon sketch template</figcaption>
|
|
34
|
+
</figure>
|
|
35
|
+
|
|
36
|
+
## Next steps
|
|
37
|
+
|
|
38
|
+
- Lear more about [Static file serving](../framework/static-file-serving.md)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
menu: GraphCMS
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
> **Developer preview**
|
|
6
|
+
> This is a developer preview of GraphCommerce. The documentation will be
|
|
7
|
+
> updated as GraphCommerce introduces
|
|
8
|
+
> [new features and refines existing functionality](https://github.com/ho-nl/m2-pwa/releases).
|
|
9
|
+
|
|
10
|
+
# GraphCMS
|
|
11
|
+
|
|
12
|
+
GraphCMS is integrated as a Content Management System. It is used to store all
|
|
13
|
+
static content and provides a user-friendly interface for managing it.
|
|
14
|
+
|
|
15
|
+
The [magento-graphcms example](./../getting-started/readme.md) offers a number
|
|
16
|
+
of components to render this content in different ways, for example in the form
|
|
17
|
+
of a page-wide hero banner, a list of USPs or grid of text columns.
|
|
18
|
+
|
|
19
|
+
This guide covers how to configure GraphCMS and how to build rich content pages
|
|
20
|
+
by adding GraphCMS content to pages.
|
|
21
|
+
|
|
22
|
+
## Configuration
|
|
23
|
+
|
|
24
|
+
To connect your GraphCommerce app to your GraphCMS project, you'll need a
|
|
25
|
+
GraphCMS project with the required schema.
|
|
26
|
+
[Clone the demo GraphCMS project](https://app.graphcms.com/clone/caddaa93cfa9436a9e76ae9c0F34d257)
|
|
27
|
+
as your starting point. Update the variable in the /.env file:
|
|
28
|
+
|
|
29
|
+
`GRAPHCMS_URL=""`
|
|
30
|
+
GraphCMS API URL. Once logged in, copy it from Project Settings > Api Access >
|
|
31
|
+
Content API
|
|
32
|
+
|
|
33
|
+
## Adding content to pages
|
|
34
|
+
|
|
35
|
+
GraphCommerce uses Next.js
|
|
36
|
+
[file-based routing ↗](https://nextjs.org/docs/routing/introduction), built on
|
|
37
|
+
the concept of pages. When a file is added to the /pages directory, it's
|
|
38
|
+
automatically available as a route. Magento category routes are handled by the
|
|
39
|
+
`/pages/[...url].tsx` page.
|
|
40
|
+
|
|
41
|
+
To add GraphCMS content to, for example, a category page, create a Page entry in
|
|
42
|
+
GraphCMS and match the value of the URL field with the route of the page you
|
|
43
|
+
wish to add content to.
|
|
44
|
+
|
|
45
|
+
For example, the content of the 'men' Page entry in GraphCMS:
|
|
46
|
+
|
|
47
|
+
<figure>
|
|
48
|
+
<img src="https://cdn-std.droplr.net/files/acc_857465/qv7IAn"/>
|
|
49
|
+
</figure>
|
|
50
|
+
|
|
51
|
+
Is used to add a`RowProduct (variant:Grid)` and a
|
|
52
|
+
`RowProduct (variant:Backstory` component to: http://localhost:3000/men
|
|
53
|
+
|
|
54
|
+
<figure>
|
|
55
|
+
<img src="https://cdn-std.droplr.net/files/acc_857465/1aSErQ" />
|
|
56
|
+
<figcaption>Content of the RowProduct (variant:Backstory component)</figcaption>
|
|
57
|
+
</figure>
|
|
58
|
+
|
|
59
|
+
<figure>
|
|
60
|
+
<img src="https://cdn-std.droplr.net/files/acc_857465/5Pkv37" />
|
|
61
|
+
</figure>
|
|
62
|
+
|
|
63
|
+
## Next steps
|
|
64
|
+
|
|
65
|
+
- Learn how to
|
|
66
|
+
[build a custom GraphCMS component](../getting-started/graphcms-component.md)
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
> **Developer preview**
|
|
2
|
+
> This is a developer preview of GraphCommerce. The documentation will be
|
|
3
|
+
> updated as GraphCommerce introduces
|
|
4
|
+
> [new features and refines existing functionality](https://github.com/ho-nl/m2-pwa/releases).
|
|
5
|
+
|
|
6
|
+
# Icons
|
|
7
|
+
|
|
8
|
+
The GraphCommerce UI looks clean and minimalistic due to the use of icons. This
|
|
9
|
+
guide covers how to customize the look of icons, how to use different icons in
|
|
10
|
+
components and how to add your own.
|
|
11
|
+
|
|
12
|
+
## Customizing icon styling
|
|
13
|
+
|
|
14
|
+
All icons strokeWidths are dependent of the value of `shape`. To change the
|
|
15
|
+
default strokeWidth, modify the value `theme.shape.strokeWidth` in
|
|
16
|
+
/components/theme.ts:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// Example from /components/theme.ts
|
|
20
|
+
|
|
21
|
+
import { svgIconStrokeWidth } from '@graphcommerce/next-ui'
|
|
22
|
+
|
|
23
|
+
const createOverrides = (theme: Theme): Components => ({
|
|
24
|
+
// ... other component styling
|
|
25
|
+
|
|
26
|
+
IconSvg: {
|
|
27
|
+
variants: [
|
|
28
|
+
{
|
|
29
|
+
props: {},
|
|
30
|
+
style: {
|
|
31
|
+
strokeWidth: svgIconStrokeWidth(28, 148, 0.9, 0.4),
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
To override the default color for all icons:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
// Example from /components/theme.ts
|
|
43
|
+
|
|
44
|
+
const createOverrides = (theme: Theme): Components => ({
|
|
45
|
+
//... other component styling
|
|
46
|
+
|
|
47
|
+
IconSvg: {
|
|
48
|
+
variants: [
|
|
49
|
+
{
|
|
50
|
+
props: {},
|
|
51
|
+
style: ({ theme }) => ({
|
|
52
|
+
color: theme.palette.primary.main,
|
|
53
|
+
}),
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Use the sx prop to customise the styling of an icon in a component:
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
<IconSvg src={iconCustomerService} size='large' sx={{ strokeWidth: '0.8px' }} />
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Using a different icon from the icon pack
|
|
67
|
+
|
|
68
|
+
To replace an icon in a component, update the import and src prop of the
|
|
69
|
+
`IconSvg` component.
|
|
70
|
+
|
|
71
|
+
In /components/Layout/LayoutFull.tsx:
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
...
|
|
75
|
+
import iconCustomerService from '@graphcommerce/next-ui'
|
|
76
|
+
|
|
77
|
+
...
|
|
78
|
+
return (
|
|
79
|
+
<IconSvg src={iconCustomerService} size='large' />
|
|
80
|
+
)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Replace iconCustomerService with an icon of your choosing:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
...
|
|
87
|
+
import iconSupport from '@graphcommerce/next-ui/icons/support.svg'
|
|
88
|
+
|
|
89
|
+
...
|
|
90
|
+
return (
|
|
91
|
+
<IconSvg src={iconSupport} size='large' />
|
|
92
|
+
)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
> All [Ikonate ↗](https://ikonate.com/) icons are included with GraphCommerce:
|
|
96
|
+
>
|
|
97
|
+
> ```txt
|
|
98
|
+
> // Sample of icons in the directory /node_modules/@graphcommerce/next-ui/icons
|
|
99
|
+
>
|
|
100
|
+
> ...
|
|
101
|
+
> └── bike.svg
|
|
102
|
+
> └── bin.svg
|
|
103
|
+
> └── bluetooth.svg
|
|
104
|
+
> └── bolt.svg
|
|
105
|
+
> └── book-opened.svg
|
|
106
|
+
> └── book.svg
|
|
107
|
+
> └── bookmark.svg
|
|
108
|
+
> └── box-alt.svg
|
|
109
|
+
> └── box-alt2.svg
|
|
110
|
+
> └── box.svg
|
|
111
|
+
> └── brightness.svg
|
|
112
|
+
> ```
|
|
113
|
+
|
|
114
|
+
## Override with the icon prop
|
|
115
|
+
|
|
116
|
+
Some components offer a prop to override the icon. In
|
|
117
|
+
/components/Layout/LayoutFull.tsx, you can add the `icon` prop to the
|
|
118
|
+
`CustomerFab` component to change the icon:
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import iconUser from '@graphcommerce/next-ui/icons/user.svg'
|
|
122
|
+
|
|
123
|
+
...
|
|
124
|
+
<CustomerFab
|
|
125
|
+
guestHref='/account/signin'
|
|
126
|
+
authHref='/account'
|
|
127
|
+
icon={<IconSvg src={iconUser} size='large' />}
|
|
128
|
+
/>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Icon SVG specifications
|
|
132
|
+
|
|
133
|
+
To use a custom icon that you design yourself, the icon must consist of paths
|
|
134
|
+
without fills. The path must be wrapped in a `<symbol>` that has an attribute
|
|
135
|
+
`id='icon'`:
|
|
136
|
+
|
|
137
|
+
```svg
|
|
138
|
+
// Example from /node_modules/@graphcommerce/next-ui/icons/chat.svg:
|
|
139
|
+
|
|
140
|
+
<svg
|
|
141
|
+
role='img'
|
|
142
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
143
|
+
width='48px'
|
|
144
|
+
height='48px'
|
|
145
|
+
aria-labelledby='chatIconTitle'
|
|
146
|
+
stroke='#2329D6'
|
|
147
|
+
stroke-width='1'
|
|
148
|
+
stroke-linecap='square'
|
|
149
|
+
stroke-linejoin='miter'
|
|
150
|
+
fill='none'
|
|
151
|
+
color='#2329D6'
|
|
152
|
+
>
|
|
153
|
+
<title id='chatIconTitle'>Chat</title>
|
|
154
|
+
<symbol id='icon' viewBox='0 0 24 24'>
|
|
155
|
+
<path d='M8.82388455,18.5880577 L4,21 L4.65322944,16.4273939 C3.00629211,15.0013 2,13.0946628 2,11 C2,6.581722 6.4771525,3 12,3 C17.5228475,3 22,6.581722 22,11 C22,15.418278 17.5228475,19 12,19 C10.8897425,19 9.82174472,18.8552518 8.82388455,18.5880577 Z' />
|
|
156
|
+
</symbol>
|
|
157
|
+
</svg>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Icons can be placed in the same directory as a page or component and can be
|
|
161
|
+
imported from there (the `<IconSvg>` component will convert the relative path to
|
|
162
|
+
an absolute path)
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
...
|
|
166
|
+
import customIcon from './my-custom-icon.svg'
|
|
167
|
+
|
|
168
|
+
...
|
|
169
|
+
return (
|
|
170
|
+
<IconSvg src={iconSucustomIconpport} size='large' />
|
|
171
|
+
)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
To use a custom icon in your component, follow the same steps as described in
|
|
175
|
+
the [previous paragraph](#using-a-different-icon-from-the-icon-pack).
|
|
176
|
+
|
|
177
|
+
> As a starting point, it's advised to open one of the included icons in your
|
|
178
|
+
> design tool (for example, Sketch or Figma).
|
|
179
|
+
|
|
180
|
+
## Using a different icon pack
|
|
181
|
+
|
|
182
|
+
To override all or multiple icons with your own, add an icon override array to
|
|
183
|
+
/theme.ts:
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
// /components/theme.ts
|
|
187
|
+
import { iconCart, iconChat } from '@graphcommerce/next-ui'
|
|
188
|
+
import customCartIcon from './my-custom-cart-icon.svg'
|
|
189
|
+
import customChatIcon from './my-custom-chat-icon.svg'
|
|
190
|
+
|
|
191
|
+
// ...
|
|
192
|
+
const createOverrides = (theme: Theme): Components => ({
|
|
193
|
+
//... other component styling
|
|
194
|
+
|
|
195
|
+
IconSvg: {
|
|
196
|
+
overrides: [
|
|
197
|
+
[iconCart, customCartIcon],
|
|
198
|
+
[iconChat, customChatIcon],
|
|
199
|
+
],
|
|
200
|
+
},
|
|
201
|
+
})
|
|
202
|
+
// ...
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
All icons must meet the svg specifications as described above
|
|
206
|
+
|
|
207
|
+
<details>
|
|
208
|
+
<summary>List of icons used</summary>
|
|
209
|
+
|
|
210
|
+
iconSearch
|
|
211
|
+
iconPerson
|
|
212
|
+
iconChevronDown
|
|
213
|
+
iconChevronLeft
|
|
214
|
+
iconChevronRight
|
|
215
|
+
iconChevronUp
|
|
216
|
+
iconAddresses
|
|
217
|
+
iconHeart
|
|
218
|
+
iconLocation
|
|
219
|
+
iconInvoice
|
|
220
|
+
iconCustomerService
|
|
221
|
+
iconShoppingBag
|
|
222
|
+
iconFullscreenExit
|
|
223
|
+
iconChat
|
|
224
|
+
iconChevronBack
|
|
225
|
+
iconCancelAlt
|
|
226
|
+
iconEmail
|
|
227
|
+
iconCheckmark
|
|
228
|
+
iconArrowBack
|
|
229
|
+
iconArrowForward
|
|
230
|
+
iconMenu
|
|
231
|
+
iconMin
|
|
232
|
+
iconPhone
|
|
233
|
+
iconPlus
|
|
234
|
+
iconClose
|
|
235
|
+
iconFullscreen
|
|
236
|
+
iconOrderBefore
|
|
237
|
+
iconBox
|
|
238
|
+
iconHome
|
|
239
|
+
iconId
|
|
240
|
+
iconLock
|
|
241
|
+
iconNewspaper
|
|
242
|
+
iconSadFace
|
|
243
|
+
iconShutdown
|
|
244
|
+
iconParty
|
|
245
|
+
iconStar
|
|
246
|
+
iconEmailOutline
|
|
247
|
+
icon404
|
|
248
|
+
iconSun
|
|
249
|
+
iconMoon
|
|
250
|
+
|
|
251
|
+
</details>
|
|
252
|
+
|
|
253
|
+
## Next steps
|
|
254
|
+
|
|
255
|
+
- Learn more about [theming](../framework/theming.md) a GraphCommerce storefront
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
menu: Overview
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
> **Developer preview**
|
|
6
|
+
> This is a developer preview of GraphCommerce. The documentation will be
|
|
7
|
+
> updated as GraphCommerce introduces
|
|
8
|
+
> [new features and refines existing functionality](https://github.com/ho-nl/m2-pwa/releases).
|
|
9
|
+
|
|
10
|
+
# GraphCommerce framework overview
|
|
11
|
+
|
|
12
|
+
GraphCommerce is a front-end framework used for building headless Magento
|
|
13
|
+
e-commerce storefronts in React. It includes the structure, components, and
|
|
14
|
+
tooling you need to get started so you can spend your time styling and designing
|
|
15
|
+
high-end e-commerce progressive web apps (PWA).
|
|
16
|
+
|
|
17
|
+
### Framework concepts and components
|
|
18
|
+
|
|
19
|
+
| Concepts | Customizing | Other |
|
|
20
|
+
| -------------------------------------------------------------- | ---------------------------------------- | -------------------------------------------------- |
|
|
21
|
+
| [Static generation](../framework/static-generation.md) | [Theming](../framework/theming.md) | [Translations](../framework/translations.md) |
|
|
22
|
+
| [Environment Variables](../framework/environment-variables.md) | [Typography](../framework/typography.md) | [Troubleshooting](../framework/troubleshooting.md) |
|
|
23
|
+
| [Deployment](../framework/deployment.md) | [Favicon](../framework/favicon.md) | [SEO](../framework/seo.md) |
|
|
24
|
+
| [GraphCMS](../framework/graphcms.md) | [Icons](../framework//icons.md) | |
|
|
25
|
+
|
|
26
|
+
## GraphCommerce project structure
|
|
27
|
+
|
|
28
|
+
When you create a GraphCommerce app, the GraphCommerce
|
|
29
|
+
[magento-graphcms example](../getting-started/readme.md) comes with a basic file
|
|
30
|
+
structure of a GraphCommerce project that's integrated with Magento and
|
|
31
|
+
GraphCMS. Most of the files that you'll work within your GraphCommerce project
|
|
32
|
+
are located in the /components or /pages directories.
|
|
33
|
+
|
|
34
|
+
- A minimal set of components you would most likely modify for your project
|
|
35
|
+
- The main layout component, which renders header, navigation, and footer
|
|
36
|
+
- A set of boilerplate pages, which handle URL routing
|
|
37
|
+
- Basic global styles in theme.ts provided by
|
|
38
|
+
[Mui ↗](https://mui.com/customization/default-theme/)
|
|
39
|
+
- Interface translation files
|
|
40
|
+
|
|
41
|
+
```txt
|
|
42
|
+
File structure of the graphcommerce-magento example
|
|
43
|
+
|
|
44
|
+
├── components
|
|
45
|
+
└── Layout
|
|
46
|
+
└── Footer.tsx
|
|
47
|
+
└── LayoutFull.tsx
|
|
48
|
+
└── GraphCMS
|
|
49
|
+
└── Asset
|
|
50
|
+
└── RowHeroBanner
|
|
51
|
+
└── RowQuote
|
|
52
|
+
└── theme.ts
|
|
53
|
+
└── ...
|
|
54
|
+
├── GraphQL
|
|
55
|
+
└── CategoryPage.graphql
|
|
56
|
+
└── PageLink.graphql
|
|
57
|
+
└── ...
|
|
58
|
+
├── pages
|
|
59
|
+
└── product
|
|
60
|
+
└── [url].jsx
|
|
61
|
+
└── ...
|
|
62
|
+
└── page
|
|
63
|
+
└── [...url].jsx
|
|
64
|
+
└── [...url].tsx
|
|
65
|
+
└── [cart].tsx
|
|
66
|
+
└── _app.tsx
|
|
67
|
+
└── _document.tsx
|
|
68
|
+
└── ...
|
|
69
|
+
├── locales
|
|
70
|
+
└── en.po
|
|
71
|
+
└── nl.po
|
|
72
|
+
└── ...
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Next steps
|
|
76
|
+
|
|
77
|
+
- Learn about [theming](../framework/theming.md) a GraphCommerce storefront
|
|
78
|
+
- Learn about [Static Generation (SSG)](../framework/static-generation.md) in
|
|
79
|
+
GraphCommerce
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
menu: SEO
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# SEO
|
|
6
|
+
|
|
7
|
+
## Page Meta data
|
|
8
|
+
|
|
9
|
+
Page meta data is handled by the
|
|
10
|
+
`import { PageMeta } from '@graphcommerce/next-ui'` component. Depending on the
|
|
11
|
+
page, the props that are passed are static or dynamic (functional page titles
|
|
12
|
+
are hardcoded).
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
// Example from /cart.tsx
|
|
16
|
+
|
|
17
|
+
<PageMeta
|
|
18
|
+
title={t`Cart (${data?.cart?.total_quantity ?? 0})`}
|
|
19
|
+
metaDescription={t`Cart Items`}
|
|
20
|
+
metaRobots={['noindex']}
|
|
21
|
+
// canonial={''}
|
|
22
|
+
/>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Dynamic example
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
// Example from /product/[url].tsx
|
|
29
|
+
|
|
30
|
+
<PageMeta
|
|
31
|
+
title={page?.metaTitle ?? title ?? ''}
|
|
32
|
+
metaDescription={page?.metaDescription ?? ''}
|
|
33
|
+
metaRobots={metaRobots}
|
|
34
|
+
canonical={`/${page?.url}`}
|
|
35
|
+
/>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Generate the XML sitemap
|
|
39
|
+
|
|
40
|
+
GraphCommerce uses
|
|
41
|
+
[next-sitemap ↗](https://github.com/iamvishnusankar/next-sitemap) to generate
|
|
42
|
+
the sitemap, which is located in the directory /public/sitemap.xml. For example,
|
|
43
|
+
view the [demo sitemap.xml ↗](https://graphcommerce.vercel.app/sitemap.xml)
|
|
44
|
+
|
|
45
|
+
Generating the sitemap.xml file is part of the static build process. Use
|
|
46
|
+
`yarn build` to initiate the build process and to generate a new sitemap.xml
|
|
47
|
+
file.
|
|
48
|
+
|
|
49
|
+
Sitemap generation uses the `NEXT_PUBLIC_SITE_URL` variable in your .env fil.
|
|
50
|
+
|
|
51
|
+
## Modify /robots.txt
|
|
52
|
+
|
|
53
|
+
GraphCommerce creates a /robots.txt file on build time. Its contents can be
|
|
54
|
+
modified by editing /next-sitemap.js. For example, view the
|
|
55
|
+
[demo robots.txt ↗](https://graphcommerce.vercel.app/robots.txt)
|
|
56
|
+
|
|
57
|
+
Generating the robot.txt file is part of the static build process. Use
|
|
58
|
+
`yarn build` to initiate the build process and to generate a new robots.txt
|
|
59
|
+
file.
|
|
60
|
+
|
|
61
|
+
## Next steps
|
|
62
|
+
|
|
63
|
+
- Learn about [Static Generation (SSG)](../framework/static-generation.md) in
|
|
64
|
+
GraphCommerce
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Static File Serving
|
|
2
|
+
|
|
3
|
+
When building your custom storefront, it can be useful to have access to static
|
|
4
|
+
files not already hosted elsewhere, like images or text documents. This guide
|
|
5
|
+
describes how to reference and serve static files in GraphCommerce.
|
|
6
|
+
|
|
7
|
+
## How static file serving works
|
|
8
|
+
|
|
9
|
+
Static files are files your app downloads from a server. Next.js serves static
|
|
10
|
+
assets at the root path /. For example, you can create a file called
|
|
11
|
+
public/icon.png and reference it in your code as /icon.png.
|
|
12
|
+
|
|
13
|
+
Product images are served from the Magento database, so you don't need to place
|
|
14
|
+
those images in the /public directory.
|
|
15
|
+
|
|
16
|
+
### Best practices
|
|
17
|
+
|
|
18
|
+
- Don't rename the /public directory as it's the only directory used to serve
|
|
19
|
+
static files. You can add subdirectories, like /public/docs
|
|
20
|
+
|
|
21
|
+
## CSS background images
|
|
22
|
+
|
|
23
|
+
CSS background images are common assets you would place in the /public
|
|
24
|
+
directory. It's a good practice to limit these to .svg images.
|
|
25
|
+
|
|
26
|
+
If you need to use a .jpg file as part of the design, place them in the /public
|
|
27
|
+
directory but render them with the `'@graphcommerce/image'` [Image component]().
|
|
28
|
+
This will benefit performance, due to the component's features such as
|
|
29
|
+
CDN-caching, srcset, and viewport loading.
|
|
30
|
+
|
|
31
|
+
## Images
|
|
32
|
+
|
|
33
|
+
Images that are part of a page or component's content (for example, product
|
|
34
|
+
images), should always be rendered with the `'@graphcommerce/image'`
|
|
35
|
+
[Image component](). This will benefit performance, due to the component's
|
|
36
|
+
features such as CDN-caching, srcset, and viewport loading.
|
|
37
|
+
|
|
38
|
+
## Next steps
|
|
39
|
+
|
|
40
|
+
- Learn more about
|
|
41
|
+
[Next.js static file serving ↗](https://nextjs.org/docs/basic-features/static-file-serving)
|
|
42
|
+
in the Next.js docs
|
|
43
|
+
- Learn how to modify your GraphCommerce app's
|
|
44
|
+
[favicon](../framework/favicon.md)
|