Skip to content

Commit

Permalink
remove lodash function as it doesn't work in edge functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Robiquet committed Mar 21, 2024
1 parent 65b34e2 commit b88cf32
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lib/constants/category-images.ts
Original file line number Diff line number Diff line change
@@ -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),
});

0 comments on commit b88cf32

Please sign in to comment.