fix: filter bundles from homepage, sitemap, and static params
Some checks failed
Build and Deploy / build (push) Has been cancelled
Some checks failed
Build and Deploy / build (push) Has been cancelled
This commit is contained in:
@@ -40,7 +40,10 @@ export default async function Homepage({ params }: { params: Promise<{ locale: s
|
|||||||
console.log("Failed to fetch products during build");
|
console.log("Failed to fetch products during build");
|
||||||
}
|
}
|
||||||
|
|
||||||
const featuredProducts = products?.slice(0, 4) || [];
|
const filteredProducts = products?.filter(
|
||||||
|
(p: any) => !p.name.includes("2x Set") && !p.name.includes("3x Set")
|
||||||
|
);
|
||||||
|
const featuredProducts = filteredProducts?.slice(0, 4) || [];
|
||||||
const hasProducts = featuredProducts.length > 0;
|
const hasProducts = featuredProducts.length > 0;
|
||||||
|
|
||||||
const basePath = `/${validLocale}`;
|
const basePath = `/${validLocale}`;
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ export async function generateStaticParams() {
|
|||||||
try {
|
try {
|
||||||
const saleorLocale = locale === "sr" ? "SR" : "EN";
|
const saleorLocale = locale === "sr" ? "SR" : "EN";
|
||||||
const products = await getProducts(saleorLocale, 100);
|
const products = await getProducts(saleorLocale, 100);
|
||||||
products.forEach((product: Product) => {
|
const filteredProducts = products.filter(
|
||||||
|
(p: Product) => !p.name.includes("2x Set") && !p.name.includes("3x Set")
|
||||||
|
);
|
||||||
|
filteredProducts.forEach((product: Product) => {
|
||||||
params.push({ locale, slug: product.slug });
|
params.push({ locale, slug: product.slug });
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -80,9 +80,13 @@ export default async function sitemap(): Promise<SitemapEntry[]> {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const filteredProducts = products.filter(
|
||||||
|
(p: any) => !p.name.includes("2x Set") && !p.name.includes("3x Set")
|
||||||
|
);
|
||||||
|
|
||||||
const productUrls: SitemapEntry[] = [];
|
const productUrls: SitemapEntry[] = [];
|
||||||
|
|
||||||
for (const product of products) {
|
for (const product of filteredProducts) {
|
||||||
const hreflangs: Record<string, string> = {};
|
const hreflangs: Record<string, string> = {};
|
||||||
for (const locale of SUPPORTED_LOCALES) {
|
for (const locale of SUPPORTED_LOCALES) {
|
||||||
const path = locale === "sr" ? `/products/${product.slug}` : `/${locale}/products/${product.slug}`;
|
const path = locale === "sr" ? `/products/${product.slug}` : `/${locale}/products/${product.slug}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user