import { defineCollection, z } from '@nuxt/content'

// 定义 Category 集合
const categoryCollection = defineCollection({
  type: 'page',
  schema: z.object({
    title: z.string(),
    description: z.string().optional(),
    id: z.string(),
    image: z.string(),
    summary: z.string(),
    capacities: z.array(z.string()),
    sort: z.number(),
  })
})

// 定义 Product 集合
const productCollection = defineCollection({
  type: 'page',
  schema: z.object({
    title: z.string(),
    name: z.string(),
    description: z.string().optional(),
    id: z.string(),
    categoryId: z.string(), // 关联类别的ID
    usage: z.array(z.string()),
    series: z.array(z.string()),
    image: z.string(),
    gallery: z.array(z.string()),
    summary: z.string(),
    capacities: z.array(z.string()),
    sort: z.number(),
    body: z.object({
      value: z.string()
    })
  })
})

// 定义 Usage 集合
const usageCollection = defineCollection({
  type: 'page',
  schema: z.object({
    title: z.string(),
    description: z.string(),
    id: z.string(),
    category: z.string(),
    products: z.array(z.string()),
    summary: z.string(),
    sort: z.number()
  })
})

// 定义 FAQ 集合
const faqCollection = defineCollection({
  type: 'page',
  schema: z.object({
    title: z.string(),
    description: z.string().optional(),
    id: z.string(),
    category: z.string(),
    question: z.string(),
    answer: z.string(),
    sort: z.number()
  })
})

// 定义默认集合
const defaultCollection = defineCollection({
  type: 'page'
})

export default {
  categories: categoryCollection,
  products: productCollection,
  usages: usageCollection,
  faq: faqCollection,
  content: defaultCollection
} 