feat: multiple category feature

This commit is contained in:
ridemountainpig
2024-01-16 11:27:57 +08:00
parent 0fc7ab88c4
commit 6d5e54b602
5 changed files with 46 additions and 13 deletions
+7 -1
View File
@@ -13,7 +13,13 @@ export const load = (async ({ params }) => {
}
// Filter out the svg with the matching slug:
const svgsByCategory = svgs.filter((svg: iSVG) => svg.category.toLowerCase() === slug);
const svgsByCategory = svgs.filter((svg: iSVG) => {
if (Array.isArray(svg.category)) {
return svg.category.some(categoryItem => categoryItem.toLowerCase() === slug);
} else {
return svg.category.toLowerCase() === slug;
}
});
return {
category: slug as string,