Foundation + Schemas
This commit is contained in:
30
src/keystatic/collections/general/articles.ts
Normal file
30
src/keystatic/collections/general/articles.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { collection, fields } from '@keystatic/core'
|
||||
|
||||
import { base } from '@/keystatic/fields/content/base'
|
||||
import { content } from '@/keystatic/fields/content/content'
|
||||
import { dates } from '@/keystatic/fields/content/dates'
|
||||
import { articleRoute } from '@/keystatic/fields/content/route'
|
||||
import { articleSummary } from '@/keystatic/fields/content/summary'
|
||||
import { ARTICLES, TAGS } from '@/lib/constants/collections'
|
||||
|
||||
export const articles = collection({
|
||||
label: 'Articles',
|
||||
slugField: 'title',
|
||||
path: `src/content/general/${ARTICLES}/*`,
|
||||
format: {
|
||||
contentField: 'content',
|
||||
},
|
||||
entryLayout: 'content',
|
||||
columns: ['title', 'status'],
|
||||
schema: {
|
||||
...base,
|
||||
route: articleRoute,
|
||||
summary: articleSummary(ARTICLES),
|
||||
dates,
|
||||
tags: fields.multiRelationship({
|
||||
label: 'Tags',
|
||||
collection: TAGS,
|
||||
}),
|
||||
content: content(ARTICLES),
|
||||
},
|
||||
})
|
||||
11
src/keystatic/collections/general/index.ts
Normal file
11
src/keystatic/collections/general/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { ARTICLES, PAGES, TAGS } from '@/lib/constants/collections'
|
||||
|
||||
import { articles } from './articles'
|
||||
import { pages } from './pages'
|
||||
import { tags } from './tags'
|
||||
|
||||
export const contentCollections = {
|
||||
[ARTICLES]: articles,
|
||||
[PAGES]: pages,
|
||||
[TAGS]: tags,
|
||||
}
|
||||
23
src/keystatic/collections/general/pages.ts
Normal file
23
src/keystatic/collections/general/pages.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { collection } from '@keystatic/core'
|
||||
|
||||
import { base } from '@/keystatic/fields/content/base'
|
||||
import { content } from '@/keystatic/fields/content/content'
|
||||
import { pageRoute } from '@/keystatic/fields/content/route'
|
||||
import { pageSummary } from '@/keystatic/fields/content/summary'
|
||||
import { PAGES } from '@/lib/constants/collections'
|
||||
|
||||
export const pages = collection({
|
||||
label: 'Pages',
|
||||
slugField: 'title',
|
||||
path: `src/content/general/${PAGES}/*`,
|
||||
format: {
|
||||
contentField: 'content',
|
||||
},
|
||||
columns: ['title', 'status'],
|
||||
schema: {
|
||||
...base,
|
||||
route: pageRoute,
|
||||
summary: pageSummary,
|
||||
content: content(PAGES),
|
||||
},
|
||||
})
|
||||
21
src/keystatic/collections/general/tags.ts
Normal file
21
src/keystatic/collections/general/tags.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { collection, fields } from '@keystatic/core'
|
||||
|
||||
import { title } from '@/keystatic/fields/content/base'
|
||||
import { TAGS } from '@/lib/constants/collections'
|
||||
|
||||
export const tags = collection({
|
||||
label: 'Tags',
|
||||
slugField: 'title',
|
||||
path: `src/content/general/${TAGS}/*`,
|
||||
format: {
|
||||
data: 'json',
|
||||
},
|
||||
columns: ['title'],
|
||||
schema: {
|
||||
title,
|
||||
description: fields.text({
|
||||
label: 'Description',
|
||||
multiline: true,
|
||||
}),
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user