import { defineType, defineField } from 'sanity';
export default defineType({
name: 'location',
title: 'Lokasjon',
type: 'document',
fields: [
defineField({
name: 'city',
title: 'By',
type: 'string',
validation: (Rule) => Rule.required(),
}),
defineField({
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'city',
maxLength: 96,
},
validation: (Rule) => Rule.required(),
}),
defineField({
name: 'region',
title: 'Region/Fylke',
type: 'string',
}),
defineField({
name: 'country',
title: 'Land',
type: 'string',
initialValue: 'Norge',
validation: (Rule) => Rule.required(),
}),
defineField({
name: 'coordinates',
title: 'Koordinater',
type: 'geopoint',
}),
defineField({
name: 'timezone',
title: 'Tidssone',
type: 'string',
initialValue: 'Europe/Oslo',
}),
defineField({
name: 'locationType',
title: 'Lokasjonstype',
type: 'string',
options: {
list: [
{ title: 'By', value: 'city' },
{ title: 'Bydel', value: 'district' },
{ title: 'Region', value: 'region' },
],
},
initialValue: 'city',
}),
],
preview: {
select: {
title: 'city',
subtitle: 'region',
},
},
});