mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
⚙️ Create utility to get categories + fix prerender function with `entries`
This commit is contained in:
+18
-1
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user