Skip to Content
SanitySchemas de SanityDocumento de Evento

Documento de Evento (event)

El tipo event representa un evento presencial de Asama Yoga: una inauguración, un taller o cualquier encuentro con fecha, ubicación e itinerario. Reemplaza el archivo apps/web/data/event.json como fuente de datos oficial.

Cuándo usar este tipo

Usa event para cada evento individual. Si necesitas una página que los liste todos (ej: /eventos), crea un documento indexPage con collectionType: "event".

Grupos de campos

El documento tiene cuatro pestañas en el Studio:

PestañaPropósito
ContenidoTítulo, imagen, textos, estado
DetallesFecha, precio, itinerario, URL de reservación
UbicaciónLugar, ciudad, estado, mapas
SEOMetadatos de búsqueda

Campos disponibles

Contenido

CampoTipoRequeridoDescripción
titlestringNombre del evento. Ej: Inauguración Asama Yoga Hermosillo
slugslugURL del evento. Ej: inauguracion-asamayoga-hermosillo/eventos/inauguracion-asamayoga-hermosillo
eyebrowstringNoEtiqueta sobre el título. Ej: EVENTO INAUGURAL
descriptiontextNoDescripción corta (para cards y previews)
longDescriptiontextNoDescripción completa del evento
imagePublicIdstringNoPublic ID de Cloudinary. Ej: SONORA_eofbow
imageAltstringNoTexto alternativo de la imagen
comingSoonbooleanNoSi está activo, el frontend oculta los detalles y muestra “Próximamente”. Default: false

Detalles

CampoTipoRequeridoDescripción
eventDatedatetimeNoFecha y hora exacta del evento (ISO 8601). Usada para filtrar eventos pasados y ordenar por proximidad. Sin este campo el evento no aparece en el listado.
datestringNoFecha en texto para mostrar en la UI. Ej: 17 de mayo, 11:00 am
dateShortstringNoVersión compacta para la UI. Ej: MAY\n17 (mes y día separados por salto de línea)
timeRangestringNoHorario completo. Ej: 11:00 am - 1:10 pm
pricestringNoPrecio formateado. Ej: MXN $300.00
priceAmountnumberNoSolo el número para lógica de pago. Ej: 300
reservationUrlstringNoURL del botón de reservación. Ej: #reservar
itineraryarrayNoLista de items con time y activity

Ubicación

CampoTipoRequeridoDescripción
locationstringNoNombre del lugar. Ej: KOVA Eventos
citystringNoCiudad. Ej: Hermosillo
stateOrProvincestringNoEstado. Ej: Sonora
mapsEmbedUrlurlNoURL del iframe de Google Maps
mapsDirectionsUrlurlNoURL de indicaciones de Google Maps

Código fuente

// schemas/documents/event.ts import { defineArrayMember, defineField, defineType } from "sanity" export const eventDocument = defineType({ name: "event", title: "Eventos", type: "document", groups: [ { name: "content", title: "Contenido", default: true }, { name: "details", title: "Detalles" }, { name: "location", title: "Ubicación" }, { name: "seo", title: "SEO" }, ], fields: [ // Contenido defineField({ name: "title", title: "Título", type: "string", ... }), defineField({ name: "slug", type: "slug", options: { source: "title" }, ... }), defineField({ name: "eyebrow", type: "string", ... }), defineField({ name: "description", type: "text", rows: 3, ... }), defineField({ name: "longDescription", type: "text", rows: 6, ... }), defineField({ name: "imagePublicId", type: "string", ... }), defineField({ name: "imageAlt", type: "string", ... }), defineField({ name: "comingSoon", type: "boolean", initialValue: false, ... }), // Detalles defineField({ name: "date", type: "string", ... }), defineField({ name: "timeRange", type: "string", ... }), defineField({ name: "price", type: "string", ... }), defineField({ name: "priceAmount", type: "number", ... }), defineField({ name: "reservationUrl", type: "string", ... }), defineField({ name: "itinerary", type: "array", of: [itineraryItem], ... }), // Ubicación defineField({ name: "location", type: "string", ... }), defineField({ name: "city", type: "string", ... }), defineField({ name: "stateOrProvince", type: "string", ... }), defineField({ name: "mapsEmbedUrl", type: "url", ... }), defineField({ name: "mapsDirectionsUrl", type: "url", ... }), // SEO defineField({ name: "seo", type: "seo", ... }), ], })

Crear un evento en el Studio

  1. En el Studio, abre el tipo Eventos en la barra lateral
  2. Haz clic en Nuevo documento
  3. Ingresa el Título y genera el Slug
  4. Si el evento aún no tiene detalles confirmados, activa Próximamente
  5. Completa la pestaña Detalles con fecha, precio e itinerario
  6. Completa la pestaña Ubicación si el lugar ya está confirmado
  7. Publica el documento

Consulta GROQ para el front-end

// Listar eventos futuros ordenados por proximidad (eventos sin fecha van al final) *[_type == "event" && (eventDate >= now() || !defined(eventDate))] | order(eventDate asc) { slug, eyebrow, title, description, longDescription, imagePublicId, imageAlt, comingSoon, date, timeRange, price, priceAmount, reservationUrl, itinerary[] { time, activity }, location, city, stateOrProvince, mapsEmbedUrl, mapsDirectionsUrl, seo { metaTitle, metaDescription, ogImage, noIndex } }
// Obtener un evento por slug *[_type == "event" && slug.current == $slug][0] { // mismos campos de arriba }

Página índice de eventos

Para crear la página /eventos que lista todos los eventos, crea un documento indexPage con collectionType: "event". El frontend es responsable de consultar los documentos event correspondientes usando GROQ.

Last updated on