diff --git a/src/keystatic/fields/general/article.ts b/src/keystatic/fields/general/article.ts new file mode 100644 index 0000000..62f5955 --- /dev/null +++ b/src/keystatic/fields/general/article.ts @@ -0,0 +1,41 @@ +import { fields } from '@keystatic/core'; + +import { createPathField } from '@/keystatic/fields/general/path'; +import { createContentField } from '@/keystatic/fields/general/content'; +import { createMetaField } from '@/keystatic/fields/general/meta'; + +export const createArticleField = ( + imageSubfolder: string, + defaultPath: string = '' +) => ({ + title: fields.slug({ + name: { + label: 'Title', + }, + }), + summary: fields.text({ + label: 'Summary', + multiline: true, + }), + path: createPathField(defaultPath), + cover: fields.object({ + src: fields.image({ + label: 'Cover Image', + directory: `public/images/covers/${imageSubfolder}`, + publicPath: `/images/covers/${imageSubfolder}`, + }), + alt: fields.text({ + label: 'Alt', + }), + caption: fields.text({ + label: 'Caption', + multiline: true, + }), + showInHeader: fields.checkbox({ + label: 'Show in Header', + defaultValue: false, + }), + }), + meta: createMetaField(), + content: createContentField(imageSubfolder), +}); diff --git a/src/keystatic/fields/general/path.ts b/src/keystatic/fields/general/path.ts new file mode 100644 index 0000000..e8af1f7 --- /dev/null +++ b/src/keystatic/fields/general/path.ts @@ -0,0 +1,8 @@ +import { ComponentSchema, fields } from '@keystatic/core'; + +export const createPathField = (defaultValue: string): ComponentSchema => + fields.text({ + label: 'Path', + description: 'Path on Website', + defaultValue: defaultValue, + });