From f615e75a0f47e951e583da8e7940195a32ecda57 Mon Sep 17 00:00:00 2001 From: David Ball Date: Tue, 16 Jul 2024 14:15:46 -0400 Subject: [PATCH] Removed category slug from 'all-categories' category, preventing the creation of that page which is functionally similar to the data on the home page. Made Category.slug optional to do so. If a category lacks a slug, no route is created for that category. --- src/data/categories.ts | 3 +-- src/pages/category/[...categoryLookup].astro | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/data/categories.ts b/src/data/categories.ts index 12e24a7..9af2f79 100644 --- a/src/data/categories.ts +++ b/src/data/categories.ts @@ -15,7 +15,7 @@ export interface Category { /** * URL slug for Product Category. */ - slug: string; + slug?: string; /** * Image for the category. */ @@ -55,7 +55,6 @@ export class StaticCategory { export const ALL_CATEGORIES = TreeNode.createRoot({ id: 0, category: "All Categories", - slug: "all-categories", description: "All categories in the whole store." }).addChild({ id: StaticCategory.nextId(), diff --git a/src/pages/category/[...categoryLookup].astro b/src/pages/category/[...categoryLookup].astro index 4116c4a..ababe2d 100644 --- a/src/pages/category/[...categoryLookup].astro +++ b/src/pages/category/[...categoryLookup].astro @@ -9,9 +9,9 @@ import { DeepArray } from '../../types/deep-array'; type CategoryStaticPath = { params: { categoryLookup: string }}; export function getStaticPaths() { - return ALL_CATEGORIES.getAllNodes().map(categoryNode => { return { + return ALL_CATEGORIES.getAllNodes().filter(categoryNode => categoryNode.value.slug !== undefined).map(categoryNode => { return { params: { - categoryLookup: categoryNode.value.slug + categoryLookup: categoryNode.value.slug! } }}); }