-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(collections): Source collections from category tree (#871)
]
- Loading branch information
Showing
25 changed files
with
952 additions
and
318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
packages/gatsby-plugin-cms/src/native-types/blocks/collection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { Seo } from './seo' | ||
import { Sort } from './sort' | ||
import type { ISeo } from './seo' | ||
import type { ISort } from './sort' | ||
import type { Schema } from '../../index' | ||
|
||
export interface ICategoryCollection { | ||
sort: keyof ISort | ||
categoryId: string | ||
} | ||
|
||
export interface IBrandCollection { | ||
sort: keyof ISort | ||
brandId: string | ||
} | ||
|
||
export interface IClusterCollection { | ||
seo: ISeo | ||
sort: keyof ISort | ||
clusterId: string | ||
} | ||
|
||
export const isCategoryCollection = ( | ||
x: ICollection | ||
): x is ICategoryCollection => typeof (x as any).categoryId === 'string' | ||
|
||
export const isBrandCollection = (x: ICollection): x is IBrandCollection => | ||
typeof (x as any).brandId === 'string' | ||
|
||
export const isClusterCollection = (x: ICollection): x is IClusterCollection => | ||
typeof (x as any).clusterId === 'string' | ||
|
||
/** | ||
* Definition of a Collection in the CMS | ||
*/ | ||
export type ICollection = | ||
| ICategoryCollection | ||
| IBrandCollection | ||
| IClusterCollection | ||
|
||
export const Collection = { | ||
title: 'Collection', | ||
description: 'Definition of a Collection for the CMS', | ||
oneOf: [ | ||
{ | ||
title: 'Category', | ||
description: 'Configure a Category', | ||
type: 'object', | ||
required: ['categoryId', 'sort'], | ||
properties: { | ||
categoryId: { | ||
title: 'Category ID', | ||
type: 'string', | ||
}, | ||
sort: Sort, | ||
}, | ||
}, | ||
{ | ||
title: 'Brand', | ||
description: 'Configure a Brand', | ||
type: 'object', | ||
required: ['brandId', 'sort'], | ||
properties: { | ||
brandId: { | ||
title: 'Brand ID', | ||
type: 'string', | ||
}, | ||
sort: Sort, | ||
}, | ||
}, | ||
{ | ||
title: 'Collection', | ||
description: 'Configure a Collection', | ||
type: 'object', | ||
required: ['clusterId', 'sort', 'seo'], | ||
properties: { | ||
clusterId: { | ||
title: 'Collection ID', | ||
type: 'string', | ||
}, | ||
sort: Sort, | ||
seo: Seo, | ||
}, | ||
}, | ||
], | ||
} as Schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { Schema } from '../..' | ||
|
||
export interface ISeo { | ||
title: string | ||
slug: string | ||
description: string | ||
} | ||
|
||
export const Seo = { | ||
type: 'object', | ||
title: 'Seo', | ||
widget: { | ||
'ui:ObjectFieldTemplate': 'GoogleSeoPreview', | ||
}, | ||
required: ['title', 'description', 'slug'], | ||
properties: { | ||
title: { | ||
type: 'string', | ||
title: 'Title', | ||
description: | ||
'Appears in the browser tab and is suggested for search engines', | ||
default: 'Page title', | ||
}, | ||
slug: { | ||
type: 'string', | ||
title: 'URL slug', | ||
description: "Final part of the page's address. No spaces allowed.", | ||
default: '/path/to/page', | ||
pattern: '^/([a-zA-Z0-9]|-|/|_)*', | ||
}, | ||
description: { | ||
type: 'string', | ||
title: 'Description (Meta description)', | ||
description: 'Suggested for search engines', | ||
default: 'Page description', | ||
}, | ||
}, | ||
} as Schema |
Oops, something went wrong.