From b88cf32a703ffa0578d4469b0c2ba37152639d59 Mon Sep 17 00:00:00 2001 From: Tom Robiquet Date: Thu, 21 Mar 2024 13:47:11 +0000 Subject: [PATCH] remove lodash function as it doesn't work in edge functions --- lib/constants/category-images.ts | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/constants/category-images.ts b/lib/constants/category-images.ts index 53f47e97f..d1bbd7dbe 100644 --- a/lib/constants/category-images.ts +++ b/lib/constants/category-images.ts @@ -1,19 +1,23 @@ -import { range } from "lodash-es"; import { union } from "lib/types/union"; import { prodTags } from "./markets"; const tags = [...prodTags, "untagged"] as const; +const generateImagePaths = (basePath: string, imageCount: number) => { + return Array(imageCount) + .fill(0) + .map((_, index) => `${basePath}/${index + 1}.png`); +}; export const CATEGORY_IMAGES = union<(typeof tags)[number]>().exhaustAsRecord({ - Sports: range(1, 6).map((i) => `/categories/sports/${i}.png`), - Politics: range(1, 5).map((i) => `/categories/politics/${i}.png`), - Technology: range(1, 5).map((i) => `/categories/tech/${i}.png`), - Crypto: range(1, 5).map((i) => `/categories/crypto/${i}.png`), - Science: range(1, 5).map((i) => `/categories/science/${i}.png`), - News: range(1, 6).map((i) => `/categories/news/${i}.png`), - Dotsama: range(1, 2).map((i) => `/categories/dotsama/${i}.png`), - Zeitgeist: range(1, 2).map((i) => `/categories/zeitgeist/${i}.png`), - Finance: range(1, 5).map((i) => `/categories/finance/${i}.png`), - Entertainment: range(1, 5).map((i) => `/categories/entertainment/${i}.png`), - untagged: range(1, 2).map((i) => `/categories/zeitgeist/${i}.png`), + Sports: generateImagePaths("/categories/sports", 5), + Politics: generateImagePaths("/categories/politics", 4), + Technology: generateImagePaths("/categories/tech", 4), + Crypto: generateImagePaths("/categories/crypto", 4), + Science: generateImagePaths("/categories/science", 4), + News: generateImagePaths("/categories/news", 5), + Dotsama: generateImagePaths("/categories/dotsama", 1), + Zeitgeist: generateImagePaths("/categories/zeitgeist", 1), + Finance: generateImagePaths("/categories/finance", 4), + Entertainment: generateImagePaths("/categories/entertainment", 4), + untagged: generateImagePaths("/categories/zeitgeist", 1), });