⚙️ Create utility to get categories + fix prerender function with `entries`
⚙️ Check app / vitest (push) Has been cancelled
⚙️ Check app / svgs-size (push) Has been cancelled

This commit is contained in:
Pablo Hdez
2024-09-24 08:41:12 +00:00
parent 863df46ff9
commit 30d9e63afe
3 changed files with 42 additions and 27 deletions
+18 -1
View File
@@ -3,4 +3,21 @@ import { svgs } from './svgs';
export const svgsData = svgs.map((svg: iSVG, index: number) => {
return { id: index, ...svg };
});
});
export const getCategories = () => {
const categories = svgs
.flatMap((svg) => (Array.isArray(svg.category) ? svg.category : [svg.category]))
.filter((category, index, array) => array.indexOf(category) === index);
return categories;
};
export const getCategoriesForDirectory = () => {
const categories = svgs
.flatMap((svg) => (Array.isArray(svg.category) ? svg.category : [svg.category]))
.filter((category, index, array) => array.indexOf(category) === index)
.map((category) => ({
slug: category.toLowerCase()
}));
return categories;
};