-
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.
- Loading branch information
Showing
11 changed files
with
299 additions
and
229 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 was deleted.
Oops, something went wrong.
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 |
38 changes: 38 additions & 0 deletions
38
packages/gatsby-plugin-cms/src/native-types/blocks/sort.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,38 @@ | ||
import type { Schema } from '../../index' | ||
|
||
export interface ISort { | ||
'""': 'Relevance' | ||
'discount:desc': 'Discount' | ||
'release:desc': 'Release date' | ||
'name:asc': 'Name, ascending' | ||
'name:desc': 'Name, descending' | ||
'orders:desc': 'Sales' | ||
'price:asc': 'Price: Low to High' | ||
'price:desc': 'Price: High to Low' | ||
} | ||
|
||
export const Sort = { | ||
title: 'Default ordering', | ||
type: 'string', | ||
default: '""', | ||
enum: [ | ||
'""', | ||
'discount:desc', | ||
'release:desc', | ||
'name:asc', | ||
'name:desc', | ||
'orders:desc', | ||
'price:asc', | ||
'price:desc', | ||
], | ||
enumNames: [ | ||
'Relevance', | ||
'Discount', | ||
'Release date', | ||
'Name, ascending', | ||
'Name, descending', | ||
'Sales', | ||
'Price: Low to High', | ||
'Price: High to Low', | ||
], | ||
} as Schema |
21 changes: 21 additions & 0 deletions
21
packages/gatsby-plugin-cms/src/native-types/contentTypes/plp.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,21 @@ | ||
import { Collection } from '../blocks/collection' | ||
import type { ContentType } from '../../index' | ||
|
||
export const PLP = ({ | ||
extraBlocks = {}, | ||
beforeBlocks = {}, | ||
afterBlocks = {}, | ||
}: Partial<Omit<ContentType, 'name'>>) => ({ | ||
plp: { | ||
name: 'PLP', | ||
extraBlocks: { | ||
...extraBlocks, | ||
Parameters: { | ||
...extraBlocks.Parameters, | ||
Collection, | ||
}, | ||
}, | ||
beforeBlocks, | ||
afterBlocks, | ||
}, | ||
}) |
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,7 @@ | ||
export { PLP } from './contentTypes/plp' | ||
|
||
export { Seo } from './blocks/seo' | ||
export type { ISeo } from './blocks/seo' | ||
|
||
export { Sort } from './blocks/sort' | ||
export type { ISort } from './blocks/sort' |
67 changes: 0 additions & 67 deletions
67
packages/gatsby-plugin-cms/src/node-api/catalog/collections.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.