import { unstable_cache } from 'next/cache'
import { getPayload } from 'payload'
import config from '@/payload.config'
import { Footer } from '@/payload-types'

export const fetchFooter = unstable_cache(
  async (): Promise<Footer> => {
    const payload = await getPayload({ config })
    return payload.findGlobal({ slug: 'footer' })
  },
  ['footer'],
  { tags: ['footer'] },
)
