Foundation + Schemas
This commit is contained in:
42
src/keystatic/fields/content/route.ts
Normal file
42
src/keystatic/fields/content/route.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { fields } from '@keystatic/core'
|
||||
|
||||
import { ARTICLES } from '@/lib/constants/collections'
|
||||
import { OPTIONAL_SEGMENT, SEGMENT_MESSAGE } from '@/lib/content/slug'
|
||||
|
||||
const segment = fields.text({
|
||||
label: 'URL segment',
|
||||
description: 'Optional- Leave empty to use the slugified title',
|
||||
validation: {
|
||||
pattern: {
|
||||
regex: OPTIONAL_SEGMENT,
|
||||
message: SEGMENT_MESSAGE,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export const pageRoute = fields.object(
|
||||
{
|
||||
segment,
|
||||
},
|
||||
{
|
||||
label: 'Route',
|
||||
},
|
||||
)
|
||||
|
||||
export const articleRoute = fields.object(
|
||||
{
|
||||
segment,
|
||||
parent: fields.relationship({
|
||||
label: 'Parent',
|
||||
description: 'Empty makes this a root',
|
||||
collection: ARTICLES,
|
||||
}),
|
||||
index: fields.integer({
|
||||
label: 'Index',
|
||||
description: 'Sorts among siblings. Empty sorts by date, newest first',
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Route',
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user