From 23a4c300cbca79aa24efba97d57dfae86bfaf2b2 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Fri, 10 Jun 2022 13:06:03 -0500 Subject: [PATCH] Add support for category slugs on kind template --- src/pages/kind/[...kindPath].astro | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/kind/[...kindPath].astro b/src/pages/kind/[...kindPath].astro index 5d471f5..8a34e79 100644 --- a/src/pages/kind/[...kindPath].astro +++ b/src/pages/kind/[...kindPath].astro @@ -9,6 +9,7 @@ import { catchRedirectResponse } from '~/helpers/astro/request.js' import { categories, getKindToCategorySlug, + getCategoryKindName, makeCategoryFilterFromCategorySlug } from '~/helpers/categories.js' @@ -33,7 +34,11 @@ if ( redirectResponse !== null ) { } -const rawKindPage = await DoesItAPI.kind( pathSlug )( subSlug ).get() +// Try the pathSlug against categories +// so we can load from category slugs +const kindName = getCategoryKindName( pathSlug ) ? getCategoryKindName( pathSlug ) : pathSlug + +const rawKindPage = await DoesItAPI.kind( kindName )( subSlug ).get() // Clean up unused kind data const kindPage = { @@ -47,7 +52,7 @@ const kindPage = { let pageLabel = 'Mac Apps' const baseFilters = [] -const categorySlug = getKindToCategorySlug( pathSlug ) +const categorySlug = getKindToCategorySlug( kindName ) // If we have a category slug, add a filter if ( !!categorySlug ) {