Added general fields
All checks were successful
Build and Deploy DAVE | DMGs Site / deploy (push) Successful in 1m30s
All checks were successful
Build and Deploy DAVE | DMGs Site / deploy (push) Successful in 1m30s
This commit is contained in:
41
src/keystatic/fields/general/article.ts
Normal file
41
src/keystatic/fields/general/article.ts
Normal file
@@ -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),
|
||||
});
|
||||
8
src/keystatic/fields/general/path.ts
Normal file
8
src/keystatic/fields/general/path.ts
Normal file
@@ -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,
|
||||
});
|
||||
Reference in New Issue
Block a user