-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SCSE-147] Update the Post schema (#74)
* fix docker-compose.yml * add slug property to Posts.ts * Update Posts.ts * add previews * fix lint (obviously on my own)
- Loading branch information
1 parent
3c9b8c6
commit 792a244
Showing
10 changed files
with
418 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,6 @@ services: | |
- --storageEngine=wiredTiger | ||
volumes: | ||
- ./data:/data/db | ||
logging: | ||
driver: none | ||
|
||
volumes: | ||
data: |
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,85 @@ | ||
import { Block, Field } from "payload/types"; | ||
import richtext from "../fields/richText/richtext"; | ||
|
||
const ContentRow: Field = { | ||
type: 'row', | ||
fields: [ | ||
{ | ||
name: 'width', | ||
label: 'Column Width', | ||
type: 'select', | ||
defaultValue: 'full', | ||
required: true, | ||
options: [ | ||
{ | ||
label: 'One Third', | ||
value: 'oneThird', | ||
}, | ||
{ | ||
label: 'Half', | ||
value: 'half', | ||
}, | ||
{ | ||
label: 'Two Thirds', | ||
value: 'twoThirds', | ||
}, | ||
{ | ||
label: 'Full Width', | ||
value: 'full', | ||
}, | ||
], | ||
admin: { | ||
width: '50%', | ||
}, | ||
}, | ||
{ | ||
name: 'alignment', | ||
label: 'Alignment', | ||
type: 'select', | ||
defaultValue: 'left', | ||
required: true, | ||
options: [ | ||
{ | ||
label: 'Left', | ||
value: 'left', | ||
}, | ||
{ | ||
label: 'Center', | ||
value: 'center', | ||
}, | ||
{ | ||
label: 'Right', | ||
value: 'right', | ||
}, | ||
], | ||
admin: { | ||
width: '50%', | ||
}, | ||
}, | ||
] | ||
} | ||
|
||
const ContentColumn: Field = { | ||
name: 'columns', | ||
type: 'array', | ||
minRows: 1, | ||
labels: { | ||
singular: 'Column', | ||
plural: 'Columns', | ||
}, | ||
fields: [ | ||
ContentRow, | ||
richtext() | ||
] | ||
} | ||
|
||
export const ContentBlock: Block = { | ||
slug: 'content', | ||
labels: { | ||
singular: 'Content', | ||
plural: 'Content Blocks', | ||
}, | ||
fields: [ | ||
ContentColumn | ||
] | ||
} |
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,84 @@ | ||
import { Block } from 'payload/types'; | ||
|
||
export const MediaBlock: Block = { | ||
slug: 'media', | ||
graphQL: { | ||
singularName: 'MediaBlock', | ||
}, | ||
labels: { | ||
singular: 'Media Block', | ||
plural: 'Media Blocks', | ||
}, | ||
fields: [ | ||
{ | ||
name: 'media', | ||
label: 'Media', | ||
type: 'upload', | ||
relationTo: 'media', | ||
required: true, | ||
admin: { | ||
description: 'Maximum upload file size: 12MB. Recommended file size for images is <500KB.', | ||
}, | ||
}, | ||
// { | ||
// name: 'useVimeo', | ||
// type: 'checkbox', | ||
// }, | ||
// { | ||
// type: 'row', | ||
// fields: [ | ||
// { | ||
// name: 'vimeoID', | ||
// label: 'Vimeo ID', | ||
// type: 'text', | ||
// required: true, | ||
// admin: { | ||
// condition: (data, { useVimeo }) => Boolean(useVimeo), | ||
// description: 'Embeds a Vimeo iframe, using the media field as its poster image.', | ||
// width: '50%', | ||
// }, | ||
// }, | ||
// aspectRatio({ | ||
// admin: { | ||
// condition: (data, { useVimeo }) => Boolean(useVimeo), | ||
// description: 'If you need to specify a different aspect ratio than 16:9, set it here.', | ||
// width: '50%', | ||
// }, | ||
// }), | ||
// ], | ||
// }, | ||
{ | ||
name: 'size', | ||
label: 'Size', | ||
type: 'radio', | ||
defaultValue: 'normal', | ||
options: [ | ||
{ | ||
label: 'Normal', | ||
value: 'normal', | ||
}, | ||
{ | ||
label: 'Wide', | ||
value: 'wide', | ||
}, | ||
{ | ||
label: 'Fullscreen', | ||
value: 'fullscreen', | ||
}, | ||
], | ||
admin: { | ||
layout: 'horizontal', | ||
}, | ||
}, | ||
{ | ||
name: 'caption', | ||
label: 'Caption', | ||
type: 'richText', | ||
admin: { | ||
elements: [ | ||
'link', | ||
], | ||
}, | ||
}, | ||
], | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { FieldHook } from "payload/types"; | ||
|
||
const populateSlug: FieldHook = ({ data }) => { | ||
const docStatus = (data?.status as string) ?? null | ||
if (docStatus !== "published") { | ||
const title = data?.title as string | ||
if (title) { | ||
return title | ||
.toLowerCase() | ||
.replace(/ /g, "-") | ||
.replace(/[^\w-]+/g, "") | ||
} | ||
} | ||
return undefined | ||
} | ||
|
||
export default populateSlug; |
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,93 @@ | ||
import { RichTextElement, RichTextField, RichTextLeaf } from 'payload/dist/fields/config/types'; | ||
import deepMerge from '../../utilities/deepMerge'; | ||
// import elements from './elements'; | ||
// import leaves from './leaves'; | ||
// import link from '../link'; | ||
|
||
type RichText = ( | ||
overrides?: Partial<RichTextField>, | ||
additions?: { | ||
elements?: RichTextElement[] | ||
leaves?: RichTextLeaf[] | ||
} | ||
) => RichTextField | ||
|
||
const richText: RichText = ( | ||
overrides, | ||
_additions = { | ||
elements: [], | ||
leaves: [], | ||
}, | ||
) => deepMerge<RichTextField, Partial<RichTextField>>( | ||
{ | ||
name: 'richText', | ||
type: 'richText', | ||
admin: { | ||
upload: { | ||
collections: { | ||
media: { | ||
fields: [ | ||
{ | ||
type: 'richText', | ||
name: 'caption', | ||
label: 'Caption', | ||
// admin: { | ||
// elements: [ | ||
// ...elements, | ||
// ], | ||
// leaves: [ | ||
// ...leaves, | ||
// ], | ||
// }, | ||
}, | ||
{ | ||
type: 'radio', | ||
name: 'alignment', | ||
label: 'Alignment', | ||
options: [ | ||
{ | ||
label: 'Left', | ||
value: 'left', | ||
}, | ||
{ | ||
label: 'Center', | ||
value: 'center', | ||
}, | ||
{ | ||
label: 'Right', | ||
value: 'right', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'enableLink', | ||
type: 'checkbox', | ||
label: 'Enable Link', | ||
}, | ||
// link({ | ||
// appearances: false, | ||
// disableLabel: true, | ||
// overrides: { | ||
// admin: { | ||
// condition: (_, data) => Boolean(data?.enableLink), | ||
// }, | ||
// }, | ||
// }), | ||
], | ||
}, | ||
}, | ||
}, | ||
// elements: [ | ||
// ...elements, | ||
// ...additions.elements || [], | ||
// ], | ||
// leaves: [ | ||
// ...leaves, | ||
// ...additions.leaves || [], | ||
// ], | ||
}, | ||
}, | ||
overrides, | ||
); | ||
|
||
export default richText; |
Oops, something went wrong.
792a244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
website-ui-storybook – ./packages/ui
website-ui-storybook-git-main-cse-it.vercel.app
storybook.ui.dev.ntuscse.com
website-ui-storybook-cse-it.vercel.app