added Meta & Content Field Collections
This commit is contained in:
4368
pnpm-lock.yaml
generated
4368
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
1
src/keystatic/components/general/index.ts
Normal file
1
src/keystatic/components/general/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const generalComponents = {};
|
||||
22
src/keystatic/fields/general/content.ts
Normal file
22
src/keystatic/fields/general/content.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { fields } from '@keystatic/core';
|
||||
import type { ContentComponent } from '@keystatic/core/content-components';
|
||||
|
||||
import { generalComponents } from '@/keystatic/components/general';
|
||||
|
||||
export const createContentField = (
|
||||
imageSubfolder: string,
|
||||
additionalComponents?: Record<string, ContentComponent>
|
||||
) =>
|
||||
fields.markdoc({
|
||||
label: 'Content',
|
||||
options: {
|
||||
image: {
|
||||
directory: `public/images/content/${imageSubfolder}`,
|
||||
publicPath: `/images/content/${imageSubfolder}`,
|
||||
},
|
||||
},
|
||||
components: {
|
||||
...generalComponents,
|
||||
...additionalComponents,
|
||||
},
|
||||
});
|
||||
52
src/keystatic/fields/general/meta.ts
Normal file
52
src/keystatic/fields/general/meta.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import type { ComponentSchema } from '@keystatic/core';
|
||||
import { fields } from '@keystatic/core';
|
||||
|
||||
export const createMetaField = (): ComponentSchema =>
|
||||
fields.object(
|
||||
{
|
||||
publicationDate: fields.datetime({
|
||||
label: 'Publication Date',
|
||||
defaultValue: {
|
||||
kind: 'now',
|
||||
},
|
||||
}),
|
||||
updateDate: fields.datetime({
|
||||
label: 'Update Date',
|
||||
}),
|
||||
status: fields.select({
|
||||
label: 'Status',
|
||||
defaultValue: 'draft',
|
||||
options: [
|
||||
{
|
||||
label: 'Draft',
|
||||
value: 'draft',
|
||||
},
|
||||
{
|
||||
label: 'Published',
|
||||
value: 'published',
|
||||
},
|
||||
{
|
||||
label: 'Archived',
|
||||
value: 'archived',
|
||||
},
|
||||
],
|
||||
}),
|
||||
tags: fields.array(
|
||||
fields.relationship({
|
||||
label: 'Tags',
|
||||
collection: 'tags',
|
||||
}),
|
||||
{
|
||||
label: 'Tags',
|
||||
itemLabel: (props) => props.value || 'Select Tags',
|
||||
}
|
||||
),
|
||||
author: fields.relationship({
|
||||
label: 'Author',
|
||||
collection: 'authors',
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Meta Information',
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user