export const metadata = { description: 'High-performance ecommerce store built with Next.js, Vercel, and Shopify.', openGraph: { type: 'website' } }; import { Carousel } from 'components/carousel'; import { ThreeItemGrid } from 'components/grid/three-items'; import { Category } from 'lib/woocomerce/models/base'; import { Product } from 'lib/woocomerce/models/product'; import { woocommerce } from 'lib/woocomerce/woocommerce'; import { wordpress } from 'lib/wordpress/wordpress'; import React from 'react'; export default async function HomePage() { const categories: Category[] = await woocommerce.get('products/categories'); const productsByCategory: Record = {}; await Promise.all( categories.map((category) => woocommerce.get('products', { category: category.id.toString() }).then((products) => { productsByCategory[category.name] = products; }) ) ); const posts = await wordpress.get('posts'); return (
{categories.map((category, index) => (
{category.name}
{category.description}
{productsByCategory[category.name] && ( )} {index === 1 && (
Top products
)}
))}
Latest posts
{posts.map((post: any) => (
{post.title.rendered}

{post.title.rendered}

))}
); }