From 29668409f871226b5f065bfaf3c75778f4c3b116 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Fri, 3 Jun 2022 16:16:59 -0500 Subject: [PATCH] Keep categoryToKind in object --- helpers/categories.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/helpers/categories.js b/helpers/categories.js index e81cf56..4b5f366 100644 --- a/helpers/categories.js +++ b/helpers/categories.js @@ -201,15 +201,17 @@ export const categories = { }, } +// Maps categories to kinds and vice versa +const categoryToKind = { + ...Object.fromEntries( Object.keys( categories ).map( key => [ key, key ] ) ), + 'homebrew': 'formula', + 'games': 'game', +} + // Respective directory for each category export function getCategoryKindName ( categorySlug ) { - if ( categorySlug === 'homebrew' ) { - return 'formula' - } - - if ( categorySlug === 'games' ) { - return 'game' - } + return categoryToKind[ categorySlug ] +} return categories[ categorySlug ].slug }