commerce/components/plp/content.tsx
Chloe d8e7553918
link dynamic content to a collection
Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
2024-07-08 08:52:10 +07:00

25 lines
626 B
TypeScript

import { getCollection, getMetaobject } from 'lib/shopify';
import DefaultContent from './default-content';
import DynamicContent from './dynamic-content';
const Content = async ({ collection }: { collection: string }) => {
const collectionData = await getCollection({ handle: collection });
if (!collectionData) {
return null;
}
if (!collectionData.dynamicContent) {
return <DefaultContent />;
}
const content = await getMetaobject({ id: collectionData.dynamicContent });
if (!content) {
return <DefaultContent />;
}
return <DynamicContent content={content} />;
};
export default Content;