@shopify/create-hydrogen 1.0.0-alpha.23 → 1.0.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/CHANGELOG.md +256 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +7 -0
- package/dist/commands/init.js +157943 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/index.js +151598 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -16
- package/templates/template-hydrogen-default/.devcontainer/devcontainer.json +18 -0
- package/templates/template-hydrogen-default/.eslintrc.js +3 -0
- package/templates/template-hydrogen-default/.gitignore +7 -0
- package/{template-hydrogen → templates/template-hydrogen-default}/.stylelintrc.js +1 -1
- package/templates/template-hydrogen-default/.vscode/extensions.json +8 -0
- package/{template-hydrogen → templates/template-hydrogen-default}/README.md +11 -2
- package/{template-hydrogen → templates/template-hydrogen-default}/_gitignore +0 -0
- package/templates/template-hydrogen-default/index.html +20 -0
- package/templates/template-hydrogen-default/package.json.liquid +48 -0
- package/{template-hydrogen → templates/template-hydrogen-default}/postcss.config.js +0 -0
- package/templates/template-hydrogen-default/public/favicon.ico +0 -0
- package/{template-hydrogen → templates/template-hydrogen-default}/shopify.config.js +1 -2
- package/templates/template-hydrogen-default/src/App.server.jsx +27 -0
- package/templates/template-hydrogen-default/src/components/Button.client.jsx +65 -0
- package/templates/template-hydrogen-default/src/components/Cart.client.jsx +265 -0
- package/templates/template-hydrogen-default/src/components/CartIcon.jsx +33 -0
- package/templates/template-hydrogen-default/src/components/CartIconWithItems.client.jsx +28 -0
- package/templates/template-hydrogen-default/src/components/CartProvider.client.jsx +35 -0
- package/templates/template-hydrogen-default/src/components/CartToggle.client.jsx +30 -0
- package/templates/template-hydrogen-default/src/components/CartUIProvider.client.jsx +45 -0
- package/templates/template-hydrogen-default/src/components/CountrySelector.client.jsx +116 -0
- package/templates/template-hydrogen-default/src/components/DefaultSeo.server.jsx +36 -0
- package/templates/template-hydrogen-default/src/components/FeaturedCollection.jsx +26 -0
- package/templates/template-hydrogen-default/src/components/Footer.server.jsx +103 -0
- package/templates/template-hydrogen-default/src/components/Gallery.client.jsx +66 -0
- package/templates/template-hydrogen-default/src/components/Header.client.jsx +62 -0
- package/templates/template-hydrogen-default/src/components/Layout.server.jsx +86 -0
- package/templates/template-hydrogen-default/src/components/LoadMoreProducts.client.jsx +56 -0
- package/templates/template-hydrogen-default/src/components/LoadingFallback.jsx +26 -0
- package/templates/template-hydrogen-default/src/components/MobileCountrySelector.client.jsx +64 -0
- package/templates/template-hydrogen-default/src/components/MobileNavigation.client.jsx +98 -0
- package/templates/template-hydrogen-default/src/components/MoneyCompareAtPrice.client.jsx +14 -0
- package/templates/template-hydrogen-default/src/components/MoneyPrice.client.jsx +15 -0
- package/templates/template-hydrogen-default/src/components/Navigation.client.jsx +23 -0
- package/templates/template-hydrogen-default/src/components/NotFound.server.jsx +93 -0
- package/templates/template-hydrogen-default/src/components/OpenIcon.jsx +33 -0
- package/templates/template-hydrogen-default/src/components/ProductCard.jsx +50 -0
- package/templates/template-hydrogen-default/src/components/ProductDetails.client.jsx +233 -0
- package/{template-hydrogen → templates/template-hydrogen-default}/src/components/ProductOptions.client.jsx +7 -4
- package/templates/template-hydrogen-default/src/components/Welcome.server.jsx +188 -0
- package/{template-hydrogen → templates/template-hydrogen-default}/src/index.css +31 -0
- package/templates/template-hydrogen-default/src/pages/collections/[handle].server.jsx +105 -0
- package/templates/template-hydrogen-default/src/pages/index.server.jsx +241 -0
- package/{template-hydrogen → templates/template-hydrogen-default}/src/pages/pages/[handle].server.jsx +14 -5
- package/templates/template-hydrogen-default/src/pages/products/[handle].server.jsx +66 -0
- package/templates/template-hydrogen-default/src/pages/redirect.server.jsx +4 -0
- package/templates/template-hydrogen-default/src/pages/robots.txt.server.js +40 -0
- package/templates/template-hydrogen-default/src/pages/sitemap.xml.server.jsx +151 -0
- package/templates/template-hydrogen-default/src/routes/collections/[handle].server.jsx +105 -0
- package/templates/template-hydrogen-default/src/routes/index.server.jsx +241 -0
- package/templates/template-hydrogen-default/src/routes/pages/[handle].server.jsx +37 -0
- package/templates/template-hydrogen-default/src/routes/products/[handle].server.jsx +66 -0
- package/templates/template-hydrogen-default/src/routes/redirect.server.jsx +4 -0
- package/templates/template-hydrogen-default/src/routes/robots.txt.server.js +40 -0
- package/templates/template-hydrogen-default/src/routes/sitemap.xml.server.jsx +151 -0
- package/templates/template-hydrogen-default/tailwind.config.js +26 -0
- package/{template-hydrogen → templates/template-hydrogen-default}/vite.config.js +1 -0
- package/templates/template-hydrogen-minimal/README.md +8 -0
- package/templates/template-hydrogen-minimal/package.json +14 -0
- package/index.js +0 -201
- package/scripts/tmp-copy-template-from-dev.js +0 -21
- package/scripts/utils.js +0 -29
- package/template-hydrogen/.eslintrc.js +0 -41
- package/template-hydrogen/.vscode/extensions.json +0 -3
- package/template-hydrogen/Dockerfile +0 -15
- package/template-hydrogen/index.html +0 -14
- package/template-hydrogen/package.json +0 -43
- package/template-hydrogen/server.js +0 -40
- package/template-hydrogen/src/App.server.jsx +0 -42
- package/template-hydrogen/src/components/Cart.client.jsx +0 -287
- package/template-hydrogen/src/components/CartProvider.client.jsx +0 -15
- package/template-hydrogen/src/components/DefaultSeo.server.jsx +0 -22
- package/template-hydrogen/src/components/Footer.jsx +0 -12
- package/template-hydrogen/src/components/Gallery.client.jsx +0 -36
- package/template-hydrogen/src/components/Header.client.jsx +0 -46
- package/template-hydrogen/src/components/HightlightedProduct.client.jsx +0 -54
- package/template-hydrogen/src/components/Layout.client.jsx +0 -61
- package/template-hydrogen/src/components/MediaPlaceholder.jsx +0 -21
- package/template-hydrogen/src/components/NotFound.server.jsx +0 -104
- package/template-hydrogen/src/components/ProductCard.client.jsx +0 -39
- package/template-hydrogen/src/components/ProductDetails.client.jsx +0 -184
- package/template-hydrogen/src/components/Seo.client.jsx +0 -75
- package/template-hydrogen/src/entry-client.jsx +0 -12
- package/template-hydrogen/src/entry-server.jsx +0 -7
- package/template-hydrogen/src/favicon.svg +0 -15
- package/template-hydrogen/src/pages/Index.server.jsx +0 -186
- package/template-hydrogen/src/pages/blogs/[handle]/[articleHandle].server.jsx +0 -49
- package/template-hydrogen/src/pages/blogs/[handle].server.jsx +0 -76
- package/template-hydrogen/src/pages/collections/[handle].server.jsx +0 -69
- package/template-hydrogen/src/pages/products/[handle].server.jsx +0 -56
- package/template-hydrogen/src/pages/search.server.jsx +0 -107
- package/template-hydrogen/src/pages/sitemap.xml.server.jsx +0 -64
- package/template-hydrogen/tailwind.config.js +0 -9
- package/template-hydrogen/worker.js +0 -22
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import {MediaFile, useShopQuery} from '@shopify/hydrogen';
|
|
2
|
-
import {useParams} from 'react-router-dom';
|
|
3
|
-
import gql from 'graphql-tag';
|
|
4
|
-
|
|
5
|
-
import Layout from '../../components/Layout.client';
|
|
6
|
-
import ProductCard from '../../components/ProductCard.client';
|
|
7
|
-
|
|
8
|
-
export default function Collection() {
|
|
9
|
-
const {handle} = useParams();
|
|
10
|
-
const {data} = useShopQuery({query: QUERY, variables: {handle}});
|
|
11
|
-
|
|
12
|
-
const collection = data.collectionByHandle;
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<Layout>
|
|
16
|
-
<h1 className="text-2xl font-bold">{collection.title}</h1>
|
|
17
|
-
|
|
18
|
-
<ul className="grid lg:grid-cols-3 gap-6 mt-4">
|
|
19
|
-
{collection.products.edges.map((edge) => (
|
|
20
|
-
<li key={edge.node.id}>
|
|
21
|
-
<ProductCard product={edge.node} />
|
|
22
|
-
</li>
|
|
23
|
-
))}
|
|
24
|
-
</ul>
|
|
25
|
-
</Layout>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const QUERY = gql`
|
|
30
|
-
fragment CollectionProductDetails on Product {
|
|
31
|
-
id
|
|
32
|
-
title
|
|
33
|
-
handle
|
|
34
|
-
priceRange {
|
|
35
|
-
maxVariantPrice {
|
|
36
|
-
amount
|
|
37
|
-
currencyCode
|
|
38
|
-
}
|
|
39
|
-
minVariantPrice {
|
|
40
|
-
amount
|
|
41
|
-
currencyCode
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
media(first: 1) {
|
|
45
|
-
edges {
|
|
46
|
-
node {
|
|
47
|
-
...MediaFileFragment
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
query CollectionDetails($handle: String!) {
|
|
54
|
-
collectionByHandle(handle: $handle) {
|
|
55
|
-
id
|
|
56
|
-
title
|
|
57
|
-
|
|
58
|
-
products(first: 10) {
|
|
59
|
-
edges {
|
|
60
|
-
node {
|
|
61
|
-
...CollectionProductDetails
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
${MediaFile.Fragment}
|
|
69
|
-
`;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {useShopQuery, ProductProviderFragment} from '@shopify/hydrogen';
|
|
2
|
-
import {useParams} from 'react-router-dom';
|
|
3
|
-
import gql from 'graphql-tag';
|
|
4
|
-
|
|
5
|
-
import ProductDetails from '../../components/ProductDetails.client';
|
|
6
|
-
import NotFound from '../../components/NotFound.server';
|
|
7
|
-
|
|
8
|
-
export default function Product() {
|
|
9
|
-
const {handle} = useParams();
|
|
10
|
-
|
|
11
|
-
const {data} = useShopQuery({
|
|
12
|
-
query: QUERY,
|
|
13
|
-
variables: {
|
|
14
|
-
handle,
|
|
15
|
-
numProductMetafields: 10,
|
|
16
|
-
numProductVariants: 250,
|
|
17
|
-
numProductMedia: 6,
|
|
18
|
-
numProductVariantMetafields: 10,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
if (!data.product) {
|
|
23
|
-
return <NotFound />;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return <ProductDetails data={data} />;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const QUERY = gql`
|
|
30
|
-
query product(
|
|
31
|
-
$handle: String!
|
|
32
|
-
$numProductMetafields: Int!
|
|
33
|
-
$numProductVariants: Int!
|
|
34
|
-
$numProductMedia: Int!
|
|
35
|
-
$numProductVariantMetafields: Int!
|
|
36
|
-
) {
|
|
37
|
-
product: productByHandle(handle: $handle) {
|
|
38
|
-
id
|
|
39
|
-
vendor
|
|
40
|
-
seo {
|
|
41
|
-
title
|
|
42
|
-
description
|
|
43
|
-
}
|
|
44
|
-
images(first: 1) {
|
|
45
|
-
edges {
|
|
46
|
-
node {
|
|
47
|
-
originalSrc
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
...ProductProviderFragment
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
${ProductProviderFragment}
|
|
56
|
-
`;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import {useEffect, useMemo, useState} from 'react';
|
|
2
|
-
import {useHistory, useLocation} from 'react-router-dom';
|
|
3
|
-
import {useShopQuery, MediaFile} from '@shopify/hydrogen';
|
|
4
|
-
import gql from 'graphql-tag';
|
|
5
|
-
|
|
6
|
-
import Layout from '../components/Layout.client';
|
|
7
|
-
import ProductCard from '../components/ProductCard.client';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* TODO: Refactor to a true server component.
|
|
11
|
-
*/
|
|
12
|
-
export default function Search() {
|
|
13
|
-
const {search} = useLocation();
|
|
14
|
-
const originalQuery = useMemo(
|
|
15
|
-
() => new URLSearchParams(search).get('query'),
|
|
16
|
-
[search],
|
|
17
|
-
);
|
|
18
|
-
const history = useHistory();
|
|
19
|
-
const [query, setQuery] = useState(originalQuery);
|
|
20
|
-
const [newQuery, setNewQuery] = useState(query);
|
|
21
|
-
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (originalQuery) {
|
|
24
|
-
setQuery(originalQuery);
|
|
25
|
-
}
|
|
26
|
-
}, [originalQuery]);
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<Layout>
|
|
30
|
-
<h1 className="text-2xl font-bold">Search</h1>
|
|
31
|
-
<form
|
|
32
|
-
onSubmit={(event) => {
|
|
33
|
-
event.preventDefault();
|
|
34
|
-
setQuery(newQuery);
|
|
35
|
-
history.push(`/search?query=${newQuery}`);
|
|
36
|
-
}}
|
|
37
|
-
className="mt-4 space-x-2"
|
|
38
|
-
>
|
|
39
|
-
<label htmlFor="search">Search Products:</label>
|
|
40
|
-
<input
|
|
41
|
-
autocomplete="off"
|
|
42
|
-
name="search"
|
|
43
|
-
id="search"
|
|
44
|
-
type="search"
|
|
45
|
-
value={newQuery}
|
|
46
|
-
onChange={(event) => setNewQuery(event.target.value)}
|
|
47
|
-
className="p-1"
|
|
48
|
-
/>
|
|
49
|
-
<button type="submit" className="bg-black text-white font-bold p-1">
|
|
50
|
-
Search
|
|
51
|
-
</button>
|
|
52
|
-
</form>
|
|
53
|
-
{query && <SearchResults query={query} />}
|
|
54
|
-
</Layout>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function SearchResults({query}) {
|
|
59
|
-
const {data, fetching} = useShopQuery({query: QUERY, variables: {query}});
|
|
60
|
-
|
|
61
|
-
if (fetching) return <p>Loading...</p>;
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<>
|
|
65
|
-
<h2 className="text-xl font-medium mt-8">Search results for: {query}</h2>
|
|
66
|
-
|
|
67
|
-
{data.products.edges.length ? (
|
|
68
|
-
<ul className="grid lg:grid-cols-3 gap-6 mt-4">
|
|
69
|
-
{data.products.edges.map((edge) => (
|
|
70
|
-
<li key={edge.node.id}>
|
|
71
|
-
<ProductCard product={edge.node} />
|
|
72
|
-
</li>
|
|
73
|
-
))}
|
|
74
|
-
</ul>
|
|
75
|
-
) : (
|
|
76
|
-
<p>No results found.</p>
|
|
77
|
-
)}
|
|
78
|
-
</>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const QUERY = gql`
|
|
83
|
-
fragment SearchProductDetails on Product {
|
|
84
|
-
id
|
|
85
|
-
title
|
|
86
|
-
handle
|
|
87
|
-
media(first: 1) {
|
|
88
|
-
edges {
|
|
89
|
-
node {
|
|
90
|
-
...MediaFileFragment
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
query ProductSearch($query: String!) {
|
|
97
|
-
products(query: $query, first: 10) {
|
|
98
|
-
edges {
|
|
99
|
-
node {
|
|
100
|
-
...SearchProductDetails
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
${MediaFile.Fragment}
|
|
107
|
-
`;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {flattenConnection, useShopQuery} from '@shopify/hydrogen';
|
|
2
|
-
import gql from 'graphql-tag';
|
|
3
|
-
|
|
4
|
-
export default function Sitemap({response}) {
|
|
5
|
-
response.doNotStream();
|
|
6
|
-
|
|
7
|
-
const {data} = useShopQuery({query: QUERY});
|
|
8
|
-
|
|
9
|
-
response.headers.set('content-type', 'application/xml');
|
|
10
|
-
|
|
11
|
-
return response.send(shopSitemap(data));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function shopSitemap(data) {
|
|
15
|
-
return `
|
|
16
|
-
<urlset
|
|
17
|
-
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
18
|
-
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
|
|
19
|
-
>
|
|
20
|
-
${flattenConnection(data.products)
|
|
21
|
-
.map((product) => {
|
|
22
|
-
return `
|
|
23
|
-
<url>
|
|
24
|
-
<loc>
|
|
25
|
-
https://hydrogen-preview.myshopify.com/products/${product.handle}
|
|
26
|
-
</loc>
|
|
27
|
-
<lastmod>${product.updatedAt}</lastmod>
|
|
28
|
-
<changefreq>daily</changefreq>
|
|
29
|
-
<image:image>
|
|
30
|
-
<image:loc>
|
|
31
|
-
${product?.images?.edges?.[0]?.node?.originalSrc}
|
|
32
|
-
</image:loc>
|
|
33
|
-
<image:title>
|
|
34
|
-
${product?.images?.edges?.[0]?.node?.altText ?? ''}
|
|
35
|
-
</image:title>
|
|
36
|
-
<image:caption />
|
|
37
|
-
</image:image>
|
|
38
|
-
</url>
|
|
39
|
-
`;
|
|
40
|
-
})
|
|
41
|
-
.join('')}
|
|
42
|
-
</urlset>`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const QUERY = gql`
|
|
46
|
-
query Products {
|
|
47
|
-
products(first: 100) {
|
|
48
|
-
edges {
|
|
49
|
-
node {
|
|
50
|
-
updatedAt
|
|
51
|
-
handle
|
|
52
|
-
images(first: 1) {
|
|
53
|
-
edges {
|
|
54
|
-
node {
|
|
55
|
-
originalSrc
|
|
56
|
-
altText
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import handleEvent from '@shopify/hydrogen/worker';
|
|
2
|
-
import entrypoint from './src/entry-server.jsx';
|
|
3
|
-
// eslint-disable-next-line node/no-missing-import
|
|
4
|
-
import indexHtml from './dist/client/index.html?raw';
|
|
5
|
-
|
|
6
|
-
addEventListener('fetch', (event) => {
|
|
7
|
-
try {
|
|
8
|
-
event.respondWith(
|
|
9
|
-
handleEvent(event, {
|
|
10
|
-
entrypoint,
|
|
11
|
-
indexTemplate: indexHtml,
|
|
12
|
-
cache: caches.default,
|
|
13
|
-
}),
|
|
14
|
-
);
|
|
15
|
-
} catch (error) {
|
|
16
|
-
event.respondWith(
|
|
17
|
-
new Response(error.message || error.toString(), {
|
|
18
|
-
status: 500,
|
|
19
|
-
}),
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
});
|