25 lines
767 B
TypeScript
25 lines
767 B
TypeScript
import { getCollectionProducts } from 'lib/shopify';
|
|
import { ProductSliderSection } from './ProductSliderSection';
|
|
|
|
/**
|
|
* Server component responsible for fetching product data
|
|
*/
|
|
export async function ProductSliderWrapper() {
|
|
// Fetch products from Shopify
|
|
// Try to fetch from a dedicated collection first, and if not available, fetch recent products
|
|
const products = await getCollectionProducts({
|
|
collection: 'hidden-homepage-carousel',
|
|
sortKey: 'CREATED_AT',
|
|
reverse: true
|
|
}).catch(() => {
|
|
return [];
|
|
});
|
|
|
|
// If no products found, don't render anything
|
|
if (!products || products.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
// Render the slider section with fetched products
|
|
return <ProductSliderSection products={products} />;
|
|
}
|