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.

This commit is contained in:
David Ball 2024-07-16 14:15:46 -04:00
parent 58a7fd8405
commit f615e75a0f
2 changed files with 3 additions and 4 deletions

View File

@ -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<Category>({
id: 0,
category: "All Categories",
slug: "all-categories",
description: "All categories in the whole store."
}).addChild({
id: StaticCategory.nextId(),

View File

@ -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!
}
}});
}