Skip to content

Commit

Permalink
use parentId
Browse files Browse the repository at this point in the history
  • Loading branch information
gabalafou committed Feb 10, 2023
1 parent 750f313 commit 5c899c3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions apps/consulting/api/types/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ export const LinksDocument = gql`
slug
isFolder
name
parentId
}
}
}
Expand Down
1 change: 1 addition & 0 deletions apps/labs/api/types/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const LinksDocument = gql`
slug
isFolder
name
parentId
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions libs/shared/utils/src/getPaths/getPaths.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { isSlugRestricted } from './isSlugRestricted';
import { TGetPaths } from './types';

export const getPaths = <LinkEntry extends { isFolder: boolean; slug: string }>(
export const getPaths = <
LinkEntry extends { isFolder: boolean; slug: string; parentId: number },
>(
items: LinkEntry[],
): TGetPaths[] =>
items
.filter(
({ isFolder, slug }) => slug && !isFolder && !isSlugRestricted(slug),
({ isFolder, slug, parentId }) =>
slug && !isFolder && !parentId && !isSlugRestricted(slug),
)
.map(({ slug }) => ({
params: {
Expand Down
4 changes: 1 addition & 3 deletions libs/shared/utils/src/getPaths/isSlugRestricted.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { restrictedSlugs } from './restrictedSlugs';

export const isSlugRestricted = (slug: string): boolean => {
return restrictedSlugs.some(
(restrictedSlug) => slug.toLowerCase() === restrictedSlug,
);
return restrictedSlugs.some((restrictedSlug) => slug === restrictedSlug);
};
9 changes: 3 additions & 6 deletions libs/shared/utils/src/getPaths/restrictedSlugs.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
export const restrictedSlugs: string[] = [
// Consulting
'homepage',
'team',
'layout',
'library',
'team-members',
'about',
'about-us',
// Labs
'home',
'team',
'blog',
];

0 comments on commit 5c899c3

Please sign in to comment.