Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
2 changes: 1 addition & 1 deletion app/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type LayoutProps = {
footer: Promise<FooterQuery>;
header: HeaderQuery;
isLoggedIn: boolean;
fetchData: any;
fetchData?: unknown;
footerMetaObject: any;
};

Expand Down
2 changes: 1 addition & 1 deletion app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {EntryContext} from '@shopify/remix-oxygen';
import {RemixServer} from '@remix-run/react';
import isbot from 'isbot';
import {isbot} from 'isbot';
import {renderToReadableStream} from 'react-dom/server';
import {createContentSecurityPolicy} from '@shopify/hydrogen';

Expand Down
12 changes: 4 additions & 8 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
Meta,
Outlet,
Scripts,
LiveReload,
useMatches,
useRouteError,
useLoaderData,
Expand All @@ -19,8 +18,8 @@ import {
} from '@remix-run/react';
import type {CustomerAccessToken} from '@shopify/hydrogen/storefront-api-types';
import favicon from '../public/favicon.svg';
import resetStyles from './styles/reset.css';
import appStyles from './styles/app.css';
import resetStyles from './styles/reset.css?url';
import appStyles from './styles/app.css?url';
import {Layout} from '~/components/Layout';
import {cssBundleHref} from '@remix-run/css-bundle';

Expand All @@ -47,7 +46,6 @@ export const shouldRevalidate: ShouldRevalidateFunction = ({

export function links() {
return [
...(cssBundleHref ? [{rel: 'stylesheet', href: cssBundleHref}] : []),
{rel: 'stylesheet', href: resetStyles},
{rel: 'stylesheet', href: appStyles},
{
Expand Down Expand Up @@ -123,12 +121,11 @@ export default function App() {
<Links />
</head>
<body>
<Layout footerMetaObject={data?.footerMetaObject} {...data}>
<Layout {...data}>
<Outlet />
</Layout>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
</body>
</html>
);
Expand Down Expand Up @@ -170,7 +167,6 @@ export function ErrorBoundary() {
</Layout>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
</body>
</html>
);
Expand Down Expand Up @@ -283,7 +279,7 @@ const FOOTER_QUERY = `#graphql
` as const;

const FOOTER_META_OBJECT_QUERY = `#graphql
query MetaObject($country: CountryCode, $language: LanguageCode)
query RootFooterMetaObject($country: CountryCode, $language: LanguageCode)
@inContext(country: $country, language: $language) {
metaobjects(first: 100, type: "footer") {
nodes {
Expand Down
26 changes: 13 additions & 13 deletions app/routes/($locale)._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {
Money,
MediaFile,
} from '@shopify/hydrogen';
import type {
CollectionFragment,
RecommendedProductsQuery,
} from 'storefrontapi.generated';
import '../styles/pages.css';
import type {LocaleIndexStoreCollectionsQuery} from 'storefrontapi.generated';

type StoreCollectionNode =
LocaleIndexStoreCollectionsQuery['collections']['nodes'][number];
import '../styles/pages.css?url';

export const meta: MetaFunction = () => {
return [{title: 'Hydrogen | Home'}];
Expand Down Expand Up @@ -77,7 +77,7 @@ function CollectionItem({
index,
className,
}: {
collection: CollectionFragment;
collection: StoreCollectionNode;
index: number;
className: string;
}) {
Expand Down Expand Up @@ -133,7 +133,7 @@ function RecommendedProducts({
metaObject,
}: {
readonly products: any;
readonly collections: readonly CollectionFragment[];
readonly collections: readonly StoreCollectionNode[];
readonly newarrivalproducts: any;
readonly bestSeller: any;
readonly topCategory: any;
Expand Down Expand Up @@ -1030,7 +1030,7 @@ const RECOMMENDED_PRODUCTS_QUERY = `#graphql
}
}
}
query RecommendedProducts ($country: CountryCode, $language: LanguageCode)
query LocaleIndexRecommendedProducts ($country: CountryCode, $language: LanguageCode)
@inContext(country: $country, language: $language) {
products(first: 3, sortKey: CREATED_AT, reverse: true) {
nodes {
Expand All @@ -1055,7 +1055,7 @@ const COLLECTIONS_QUERY = `#graphql
height
}
}
query StoreCollections(
query LocaleIndexStoreCollections(
$country: CountryCode
$endCursor: String
# $first: Int
Expand Down Expand Up @@ -1092,7 +1092,7 @@ const COLLECTIONS_QUERY = `#graphql
` as const;

const NEW_ARRIVALS_QUERY = `#graphql
query FeaturedCollection($country: CountryCode, $language: LanguageCode)
query LocaleIndexNewArrivalsCollection($country: CountryCode, $language: LanguageCode)
@inContext(country: $country, language: $language) {
collection(handle: "new-arrivals") {
handle
Expand All @@ -1116,7 +1116,7 @@ query FeaturedCollection($country: CountryCode, $language: LanguageCode)
}` as const;

const TOP_CATEGORIES_QUERY = `#graphql
query FeaturedCollection($country: CountryCode, $language: LanguageCode)
query LocaleIndexTopCategoriesCollection($country: CountryCode, $language: LanguageCode)
@inContext(country: $country, language: $language) {
collections(first:8, reverse:true) {
edges {
Expand Down Expand Up @@ -1148,7 +1148,7 @@ const TOP_CATEGORIES_QUERY = `#graphql
` as const;

const BEST_SELLER_QUERY = `#graphql
query FeaturedCollection($country: CountryCode, $language: LanguageCode)
query LocaleIndexBestSellerCollection($country: CountryCode, $language: LanguageCode)
@inContext(country: $country, language: $language) {
collection(handle: "womens-fashion") {
handle
Expand All @@ -1172,7 +1172,7 @@ query FeaturedCollection($country: CountryCode, $language: LanguageCode)
}` as const;

const META_OBJECT_QUERY = `#graphql
query MetaObject($country: CountryCode, $language: LanguageCode)
query LocaleIndexHomeMetaObject($country: CountryCode, $language: LanguageCode)
@inContext(country: $country, language: $language) {
metaobjects(first: 100, type: "home") {
nodes {
Expand Down
4 changes: 2 additions & 2 deletions app/routes/($locale).about.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {defer, type LoaderFunctionArgs} from '@shopify/remix-oxygen';
import parse from 'html-react-parser';
import {useLoaderData, type MetaFunction} from '@remix-run/react';
import '../styles/pages.css';
import '../styles/pages.css?url';

export const meta: MetaFunction = () => {
return [{title: 'Hydrogen | About Us'}];
Expand Down Expand Up @@ -58,7 +58,7 @@ function RecommendedProducts({metaObject}: {metaObject: any}) {
}

const META_OBJECT_QUERY = `#graphql
query MetaObject($country: CountryCode, $language: LanguageCode)
query AboutPageMetaObject($country: CountryCode, $language: LanguageCode)
@inContext(country: $country, language: $language) {
metaobjects(first: 100, type: "about_us") {
nodes {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/($locale).account.orders._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
CustomerOrdersFragment,
OrderItemFragment,
} from 'storefrontapi.generated';
import '../styles/pages.css';
import '../styles/pages.css?url';

export const meta: MetaFunction = () => {
return [{title: 'Orders'}];
Expand Down
2 changes: 1 addition & 1 deletion app/routes/($locale).account.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
useOutletContext,
type MetaFunction,
} from '@remix-run/react';
import '../styles/pages.css';
import '../styles/pages.css?url';

export type ActionResponse = {
error: string | null;
Expand Down
2 changes: 1 addition & 1 deletion app/routes/($locale).account.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Form, NavLink, Outlet, useLoaderData} from '@remix-run/react';
import {json, redirect, type LoaderFunctionArgs} from '@shopify/remix-oxygen';
import type {CustomerFragment} from 'storefrontapi.generated';
import '../styles/pages.css';
import '../styles/pages.css?url';

export function shouldRevalidate() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion app/routes/($locale).account_.login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type LoaderFunctionArgs,
} from '@shopify/remix-oxygen';
import {Form, Link, useActionData, type MetaFunction} from '@remix-run/react';
import '../styles/pages.css';
import '../styles/pages.css?url';

type ActionResponse = {
error: string | null;
Expand Down
3 changes: 1 addition & 2 deletions app/routes/($locale).cart.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Await, type MetaFunction} from '@remix-run/react';
import {Suspense} from 'react';
import type {CartQueryData} from '@shopify/hydrogen';
import {CartForm} from '@shopify/hydrogen';
import {json, type ActionFunctionArgs} from '@shopify/remix-oxygen';
import {CartMain} from '~/components/Cart';
Expand All @@ -25,7 +24,7 @@ export async function action({request, context}: ActionFunctionArgs) {
}

let status = 200;
let result: CartQueryData;
let result: Awaited<ReturnType<(typeof cart)['addLines']>>;

switch (action) {
case CartForm.ACTIONS.LinesAdd:
Expand Down
2 changes: 1 addition & 1 deletion app/routes/($locale).collections.$handle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@shopify/hydrogen';
import type {ProductItemFragment} from 'storefrontapi.generated';
import {useVariantUrl} from '~/utils';
import '../styles/pages.css';
import '../styles/pages.css?url';

export const meta: MetaFunction<typeof loader> = ({data}) => {
return [{title: `Hydrogen | ${data?.collection.title ?? ''} Collection`}];
Expand Down
6 changes: 3 additions & 3 deletions app/routes/($locale).collections._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {useLoaderData, Link} from '@remix-run/react';
import {json, type LoaderFunctionArgs} from '@shopify/remix-oxygen';
import {Pagination, getPaginationVariables, Image} from '@shopify/hydrogen';
import type {CollectionFragment} from 'storefrontapi.generated';
import '../styles/pages.css';
import '../styles/pages.css?url';

export const meta: MetaFunction = () => {
return [{title: 'Hydrogen | Collections'}];
Expand Down Expand Up @@ -114,7 +114,7 @@ const COLLECTIONS_QUERY = `#graphql
height
}
}
query StoreCollections(
query CollectionsListingStoreCollections(
$country: CountryCode
$endCursor: String
$first: Int
Expand Down Expand Up @@ -142,7 +142,7 @@ const COLLECTIONS_QUERY = `#graphql
` as const;

const HEADING_QUERY = `#graphql
query MetaObject($country: CountryCode, $language: LanguageCode)
query CollectionsListingMetaObject($country: CountryCode, $language: LanguageCode)
@inContext(country: $country, language: $language) {
metaobjects(first: 100, type: "product_page_contents") {
nodes {
Expand Down
10 changes: 5 additions & 5 deletions app/routes/($locale).collections.all.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Money,
Pagination,
} from '@shopify/hydrogen';
import '../styles/pages.css';
import '../styles/pages.css?url';
import NoImg from '../../public/NoImg.svg';

export const meta: MetaFunction = () => {
Expand Down Expand Up @@ -183,7 +183,7 @@ function RecommendedProducts({
}

const RECOMMENDED_PRODUCTS_QUERY = `#graphql
fragment Product on Product {
fragment CollectionAllProduct on Product {
id
title
handle
Expand Down Expand Up @@ -214,7 +214,7 @@ const RECOMMENDED_PRODUCTS_QUERY = `#graphql
}
}
}
query RecommendedProducts ( $country: CountryCode
query CollectionsAllPagedRecommendedProducts ( $country: CountryCode
$endCursor: String
$first: Int
$language: LanguageCode
Expand All @@ -229,7 +229,7 @@ const RECOMMENDED_PRODUCTS_QUERY = `#graphql
reverse: true
) {
nodes {
...Product
...CollectionAllProduct
}
pageInfo {
hasNextPage
Expand All @@ -242,7 +242,7 @@ const RECOMMENDED_PRODUCTS_QUERY = `#graphql
` as const;

const HEADING_QUERY = `#graphql
query MetaObject($country: CountryCode, $language: LanguageCode)
query CollectionsAllProductPageMetaObject($country: CountryCode, $language: LanguageCode)
@inContext(country: $country, language: $language) {
metaobjects(first: 100, type: "product_page_contents") {
nodes {
Expand Down
19 changes: 10 additions & 9 deletions app/routes/($locale).products.$handle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export async function loader({params, request, context}: LoaderFunctionArgs) {

// await the query for the critical product data
const {product} = await storefront.query(PRODUCT_QUERY, {
variables: {handle, key, selectedOptions},
variables: {handle, key: key ?? '', selectedOptions},
});
if (!product?.id) {
throw new Response(null, {status: 404});
Expand Down Expand Up @@ -467,7 +467,7 @@ function ProductMain({
<strong>Reviews</strong>
</p>
<br />
<div>{parse(valueMap.get('product_review') || '')}</div>
<div>{parse(String(valueMap.get('product_review') ?? ''))}</div>
<br />
</>
)}
Expand All @@ -478,7 +478,7 @@ function ProductMain({
<strong>Shipping and Return</strong>
</p>
<br />
<div>{parse(valueMap.get('shipping_return_policy') || '')}</div>
<div>{parse(String(valueMap.get('shipping_return_policy') ?? ''))}</div>
<br />
</>
)}
Expand Down Expand Up @@ -681,14 +681,14 @@ function ProductForm({
<AddToCartButton
disabled={!selectedVariant || !selectedVariant?.availableForSale}
lines={
selectedVariant
(selectedVariant
? [
{
merchandiseId: selectedVariant?.id,
merchandiseId: selectedVariant.id,
quantity: 1,
},
]
: []
: []) as any
}
cart={cart}
/>
Expand Down Expand Up @@ -825,7 +825,8 @@ function AddToCartButton({
<span className="totalquantiy">{quantity}</span>
<CartForm
route="/cart"
inputs={{lines: cart === null ? lines : updatedLines}}
// Cart line shapes from the Storefront API differ slightly from CartForm’s strict union after Hydrogen 2025.
inputs={{lines: cart === null ? lines : updatedLines} as any}
action={
cart === null
? CartForm.ACTIONS.LinesAdd
Expand Down Expand Up @@ -1048,7 +1049,7 @@ const RELATED_PRODUCT_QUERY = `#graphql
` as const;

const META_OBJECT_QUERY = `#graphql
query MetaObject($country: CountryCode, $language: LanguageCode, $first: Int, $after: String)
query ProductDetailPagedMetaObject($country: CountryCode, $language: LanguageCode, $first: Int, $after: String)
@inContext(country: $country, language: $language) {
metaobjects(first: $first, after: $after, type: "product_detail_page") {
edges {
Expand All @@ -1075,7 +1076,7 @@ query MetaObject($country: CountryCode, $language: LanguageCode, $first: Int, $a
}` as const;

const HEADING_QUERY = `#graphql
query MetaObject($country: CountryCode, $language: LanguageCode)
query ProductHandleProductPageMetaObject($country: CountryCode, $language: LanguageCode)
@inContext(country: $country, language: $language) {
metaobjects(first: 100, type: "product_page_contents") {
nodes {
Expand Down
Loading
Loading