mirror of
https://github.com/lux-tel/websites.git
synced 2026-10-30 20:31:36 +00:00
23 lines
534 B
TypeScript
23 lines
534 B
TypeScript
import { type SlugRule, defineField } from 'sanity';
|
|
|
|
export const slugFieldDefinition = {
|
|
name: 'slug' as const,
|
|
type: 'slug' as const,
|
|
title: 'Slug',
|
|
options: {
|
|
source: 'label',
|
|
},
|
|
validation: (Rule: SlugRule) =>
|
|
Rule.required()
|
|
.custom((slug) => {
|
|
if (!slug?.current) return true;
|
|
if (slug.current.startsWith('/')) {
|
|
return 'The slug cannot start with a "/"';
|
|
}
|
|
return true;
|
|
})
|
|
.error(),
|
|
};
|
|
|
|
export const slugField = defineField(slugFieldDefinition);
|