import { getCollection, getMetaobjectsByIds } from 'lib/shopify';
import { Metaobject } from 'lib/shopify/types';
import Link from 'next/link';
const { STORE_PREFIX } = process.env;
const validStores = ['car-part-planet', 'reman-engine', 'engine-locator'];
const LinkBlock = async ({ collectionId, title }: { collectionId?: string; title?: string }) => {
if (!collectionId || !title) return null;
const collection = await getCollection({ id: collectionId });
if (!collection) return null;
return (
{title}
);
};
const EngineSizes = async ({ collectionHandle }: { collectionHandle: string }) => {
const collection = await getCollection({ handle: collectionHandle });
if (!collection || !collection.plpType || !validStores.includes(STORE_PREFIX!)) {
return null;
}
let engineSizes = [] as Metaobject[];
if (collection.plpType === 'Product Type' && collection.engineSizeLinks) {
engineSizes = await getMetaobjectsByIds(collection.engineSizeLinks);
}
if (!engineSizes.length) {
return null;
}
return (
Browse Engines By Engine Sizes
{engineSizes.map((engineSize) => (
))}
);
};
export default EngineSizes;