From 944a0263d44a5ab551ee1ddcb7c864af889a5de9 Mon Sep 17 00:00:00 2001 From: Leidison Siqueira Barbosa Date: Mon, 11 Jan 2021 12:21:18 -0300 Subject: [PATCH] Update index.tsx The change prevents the duplication of products featured on the home page. --- pages/index.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pages/index.tsx b/pages/index.tsx index ef1c0a96e..9665ce236 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -45,6 +45,9 @@ export async function getStaticProps({ const { featured, bestSelling } = (() => { // Create a copy of products that we can mutate const products = [...newestProducts] + .filter((product) => !featuredProducts + .map((product) => product.node.entityId) + .includes(product.node.entityId)) // If the lists of featured and best selling products don't have enough // products, then fill them with products from the products list, this // is useful for new commerce sites that don't have a lot of products