Merge branch 'main' into demo-refresh

This commit is contained in:
Michael Novotny 2023-04-21 13:12:41 -05:00 committed by GitHub
commit ee3db897d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 9 deletions

View File

@ -10,7 +10,7 @@ export const metadata = {
openGraph: { openGraph: {
images: [ images: [
{ {
url: `/api/og?title=${encodeURIComponent(process.env.SITE_NAME)}`, url: `/api/og?title=${encodeURIComponent(process.env.SITE_NAME || '')}`,
width: 1200, width: 1200,
height: 630 height: 630
} }

View File

@ -99,7 +99,7 @@ export default async function ProductPage({ params }: { params: { handle: string
async function RelatedProducts({ id }: { id: string }) { async function RelatedProducts({ id }: { id: string }) {
const relatedProducts = await getProductRecommendations(id); const relatedProducts = await getProductRecommendations(id);
if (!relatedProducts) return null; if (!relatedProducts.length) return null;
return ( return (
<div className="px-4 py-8"> <div className="px-4 py-8">

View File

@ -37,7 +37,7 @@ function ThreeItemGridItem({
export async function ThreeItemGrid() { export async function ThreeItemGrid() {
// Collections that start with `hidden-*` are hidden from the search page. // 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; if (!homepageItems[0] || !homepageItems[1] || !homepageItems[2]) return null;

View File

@ -256,12 +256,11 @@ export async function getCollection(handle: string): Promise<Collection | undefi
return reshapeCollection(res.body.data.collection); 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>({ const res = await shopifyFetch<ShopifyCollectionProductsOperation>({
query: getCollectionProductsQuery, query: getCollectionProductsQuery,
variables: { variables: {
handle, handle
first: limit
} }
}); });

View File

@ -36,9 +36,9 @@ export const getCollectionsQuery = /* GraphQL */ `
`; `;
export const getCollectionProductsQuery = /* GraphQL */ ` export const getCollectionProductsQuery = /* GraphQL */ `
query getCollectionProducts($handle: String!, $first: Int = 100) { query getCollectionProducts($handle: String!) {
collection(handle: $handle) { collection(handle: $handle) {
products(first: $first) { products(first: 100) {
edges { edges {
node { node {
...product ...product

View File

@ -199,7 +199,6 @@ export type ShopifyCollectionProductsOperation = {
}; };
variables: { variables: {
handle: string; handle: string;
first?: number;
}; };
}; };