import { Blog } from '@/payload-types'
import { Slide } from '@/compositions/ImageCardSlider/ImageCardSlider'
import { getPhoto } from '@/utils/dto/gallery'

export const blogToSlides = (blog: Blog[]): Slide[] => {
  return blog.map(b => {
    const image = getPhoto("thumbnail", b.photo)
    return {
      id: b.id,
      title: b.title,
      href: `/blog/${b.id}`,
      src: typeof image === "object" ? image.src : ""
    }
  })
}