mirror of
https://github.com/vercel/commerce.git
synced 2025-05-16 14:36:59 +00:00
Merge branch 'main' into demo-refresh
This commit is contained in:
commit
ee3db897d4
@ -10,7 +10,7 @@ export const metadata = {
|
||||
openGraph: {
|
||||
images: [
|
||||
{
|
||||
url: `/api/og?title=${encodeURIComponent(process.env.SITE_NAME)}`,
|
||||
url: `/api/og?title=${encodeURIComponent(process.env.SITE_NAME || '')}`,
|
||||
width: 1200,
|
||||
height: 630
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ export default async function ProductPage({ params }: { params: { handle: string
|
||||
async function RelatedProducts({ id }: { id: string }) {
|
||||
const relatedProducts = await getProductRecommendations(id);
|
||||
|
||||
if (!relatedProducts) return null;
|
||||
if (!relatedProducts.length) return null;
|
||||
|
||||
return (
|
||||
<div className="px-4 py-8">
|
||||
|
@ -37,7 +37,7 @@ function ThreeItemGridItem({
|
||||
|
||||
export async function ThreeItemGrid() {
|
||||
// Collections that start with `hidden-*` are hidden from the search page.
|
||||
const homepageItems = await getCollectionProducts('hidden-homepage-featured-items', 3);
|
||||
const homepageItems = await getCollectionProducts('hidden-homepage-featured-items');
|
||||
|
||||
if (!homepageItems[0] || !homepageItems[1] || !homepageItems[2]) return null;
|
||||
|
||||
|
@ -256,12 +256,11 @@ export async function getCollection(handle: string): Promise<Collection | undefi
|
||||
return reshapeCollection(res.body.data.collection);
|
||||
}
|
||||
|
||||
export async function getCollectionProducts(handle: string, limit?: number): Promise<Product[]> {
|
||||
export async function getCollectionProducts(handle: string): Promise<Product[]> {
|
||||
const res = await shopifyFetch<ShopifyCollectionProductsOperation>({
|
||||
query: getCollectionProductsQuery,
|
||||
variables: {
|
||||
handle,
|
||||
first: limit
|
||||
handle
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -36,9 +36,9 @@ export const getCollectionsQuery = /* GraphQL */ `
|
||||
`;
|
||||
|
||||
export const getCollectionProductsQuery = /* GraphQL */ `
|
||||
query getCollectionProducts($handle: String!, $first: Int = 100) {
|
||||
query getCollectionProducts($handle: String!) {
|
||||
collection(handle: $handle) {
|
||||
products(first: $first) {
|
||||
products(first: 100) {
|
||||
edges {
|
||||
node {
|
||||
...product
|
||||
|
@ -199,7 +199,6 @@ export type ShopifyCollectionProductsOperation = {
|
||||
};
|
||||
variables: {
|
||||
handle: string;
|
||||
first?: number;
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user