church-website/src/fetch/prayers.ts
2026-03-11 11:29:16 +01:00

16 lines
425 B
TypeScript

import { unstable_cache } from 'next/cache'
import { getPayload } from 'payload'
import config from '@/payload.config'
export const fetchPrayers = unstable_cache(
async (): Promise<string[]> => {
const payload = await getPayload({ config })
const data = await payload.find({
collection: 'prayers',
limit: 0,
})
return data.docs.map((p) => p.text)
},
['prayers'],
{ tags: ['prayers'] },
)