101 lines
4.3 KiB
TypeScript
101 lines
4.3 KiB
TypeScript
import type { CollectionConfig } from 'payload'
|
||
import { ADMIN_GROUP } from '../admin/groups'
|
||
|
||
export const Banners: CollectionConfig = {
|
||
slug: 'banners',
|
||
labels: { singular: 'Баннер', plural: 'Баннеры' },
|
||
admin: {
|
||
group: ADMIN_GROUP.content,
|
||
useAsTitle: 'title',
|
||
defaultColumns: ['title', 'sortOrder', 'isPublished', 'updatedAt'],
|
||
description: 'Слайды главного баннера на главной странице. Порядок, тексты, кнопки, фото и видео задаются здесь.',
|
||
},
|
||
access: { read: () => true },
|
||
defaultSort: 'sortOrder',
|
||
fields: [
|
||
{
|
||
type: 'tabs',
|
||
tabs: [
|
||
{
|
||
label: 'Текст',
|
||
fields: [
|
||
{ name: 'eyebrow', type: 'text', localized: true, label: 'Надзаголовок', admin: { description: 'Например, МОНИКИ' } },
|
||
{ name: 'title', type: 'text', required: true, localized: true, label: 'Заголовок' },
|
||
{ name: 'subtitle', type: 'textarea', localized: true, label: 'Подзаголовок' },
|
||
{ name: 'phone', type: 'text', label: 'Телефон' },
|
||
{ name: 'address', type: 'text', localized: true, label: 'Адрес' },
|
||
],
|
||
},
|
||
{
|
||
label: 'Медиа',
|
||
fields: [
|
||
{
|
||
name: 'image',
|
||
type: 'upload',
|
||
relationTo: 'media',
|
||
label: 'Фото слайда',
|
||
admin: { description: 'Постер, если есть видео, или основное изображение слайда.' },
|
||
},
|
||
{
|
||
name: 'imageUrl',
|
||
type: 'text',
|
||
label: 'URL фото (если не загружено в медиа)',
|
||
admin: { description: 'Например /hero/diagnostics.jpg' },
|
||
},
|
||
{ name: 'imageAlt', type: 'text', localized: true, label: 'Alt фото' },
|
||
{
|
||
name: 'video',
|
||
type: 'upload',
|
||
relationTo: 'media',
|
||
label: 'Видео слайда',
|
||
admin: { description: 'Если задано, на слайде показывается видео. Запускается по клику.' },
|
||
},
|
||
{
|
||
name: 'videoUrl',
|
||
type: 'text',
|
||
label: 'URL видео (если не загружено в медиа)',
|
||
admin: { description: 'Например /hero/250-white.mp4' },
|
||
},
|
||
{
|
||
name: 'background',
|
||
type: 'upload',
|
||
relationTo: 'media',
|
||
label: 'Фон организации',
|
||
admin: { description: 'Размытый фон секции. Если пусто — используется фото здания МОНИКИ.' },
|
||
},
|
||
{
|
||
name: 'backgroundUrl',
|
||
type: 'text',
|
||
label: 'URL фона (если не загружено в медиа)',
|
||
},
|
||
],
|
||
},
|
||
{
|
||
label: 'Кнопки',
|
||
fields: [
|
||
{ name: 'ctaPrimaryLabel', type: 'text', localized: true, label: 'Основная кнопка' },
|
||
{ name: 'ctaPrimaryHref', type: 'text', label: 'Ссылка основной кнопки' },
|
||
{ name: 'ctaSecondaryLabel', type: 'text', localized: true, label: 'Вторая кнопка' },
|
||
{ name: 'ctaSecondaryHref', type: 'text', label: 'Ссылка второй кнопки' },
|
||
],
|
||
},
|
||
{
|
||
label: 'Показ',
|
||
fields: [
|
||
{ name: 'slug', type: 'text', required: true, unique: true, label: 'Символьный код' },
|
||
{ name: 'sortOrder', type: 'number', defaultValue: 0, label: 'Порядок' },
|
||
{
|
||
name: 'durationMs',
|
||
type: 'number',
|
||
defaultValue: 7000,
|
||
label: 'Время показа (мс)',
|
||
admin: { description: 'Автопереключение слайда, 5000–12000' },
|
||
},
|
||
{ name: 'isPublished', type: 'checkbox', defaultValue: true, label: 'Опубликован' },
|
||
],
|
||
},
|
||
],
|
||
},
|
||
],
|
||
}
|