added Meta & Content Field Collections

This commit is contained in:
2025-11-11 13:49:31 +01:00
parent abb694bf5b
commit af7a72d174
5 changed files with 3987 additions and 1296 deletions

View File

@@ -0,0 +1 @@
export const generalComponents = {};

View 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,
},
});

View 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',
}
);