From 631d8613246911822a6517ef2e66bde900cd6fee Mon Sep 17 00:00:00 2001 From: Chloe Date: Wed, 10 Jul 2024 08:49:36 +0700 Subject: [PATCH] add default content for PLP page Signed-off-by: Chloe --- components/plp/content.tsx | 4 ++-- components/plp/default-content.tsx | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/components/plp/content.tsx b/components/plp/content.tsx index d3dfefc03..b0cc6a136 100644 --- a/components/plp/content.tsx +++ b/components/plp/content.tsx @@ -5,12 +5,12 @@ import DynamicContent from './dynamic-content'; const Content = async ({ collection }: { collection: Collection }) => { if (!collection.dynamicContent) { - return ; + return ; } const content = await getMetaobject({ id: collection.dynamicContent }); if (!content) { - return ; + return ; } return ; diff --git a/components/plp/default-content.tsx b/components/plp/default-content.tsx index e1da6933a..88a04a4d9 100644 --- a/components/plp/default-content.tsx +++ b/components/plp/default-content.tsx @@ -1,11 +1,27 @@ import Tag from 'components/tag'; import { getMetaobject } from 'lib/shopify'; +import { Collection } from 'lib/shopify/types'; import { Suspense } from 'react'; import Tabs, { TabsPlaceholder } from './tabs'; -const DefaultContent = async () => { +const DefaultContent = async ({ collection }: { collection: Collection }) => { + let handle = 'default-plp-content'; + + if (collection.handle.startsWith('transmissions')) { + handle = 'transmissions-plp-content'; + } + if ( + collection.handle.startsWith('engines') || + collection.handle.startsWith('remanufactured-engines') + ) { + handle = 'engines-plp-content'; + } + if (collection.handle.startsWith('transfer-cases')) { + handle = 'transfer-cases-plp-content'; + } + const defaultPLPContent = await getMetaobject({ - handle: { handle: 'default-plp-content', type: 'plp_content' } + handle: { handle, type: 'plp_content' } }); if (!defaultPLPContent) {