Skip to content

Commit 61a0b72

Browse files
committed
update getGlobal
1 parent bb4249a commit 61a0b72

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/Footer/Component.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ import { LanguageSelector } from './Locale'
99
import { CMSLink } from '@/components/Link'
1010
import { Logo } from '@/components/Logo/Logo'
1111

12+
import { getLocale } from 'next-intl/server'
13+
import { Locale } from '@/i18n/types'
14+
1215
export async function Footer() {
13-
const footerData: Footer = await getCachedGlobal('footer', 1)()
16+
const locale = (await getLocale()) as Locale
17+
18+
const footerData: Footer = await getCachedGlobal('footer', 1)(locale)
1419
const navItems = footerData?.navItems || []
1520

1621
return (

src/Header/Component.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import React from 'react'
44

55
import type { Header } from '@/payload-types'
66

7-
import { findFeedBySlug } from '@/queries/feeds'
7+
import { getLocale } from 'next-intl/server'
8+
import { Locale } from '@/i18n/types'
89

910
export async function Header() {
10-
const headerData: Header = await getCachedGlobal('header', 1)()
11+
const locale = (await getLocale()) as Locale
12+
13+
const headerData: Header = await getCachedGlobal('header', 1)(locale)
1114

1215
return <HeaderClient data={headerData} />
1316
}

src/utilities/getGlobals.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ import configPromise from '@payload-config'
44
import { getPayload } from 'payload'
55
import { unstable_cache } from 'next/cache'
66

7-
import { getLocale } from 'next-intl/server'
87
import { Locale } from '@/i18n/types'
98

109
type Global = keyof Config['globals']
1110

12-
async function getGlobal(slug: Global, depth = 0) {
13-
const locale = (await getLocale()) as Locale
14-
11+
async function getGlobal(slug: Global, depth = 0, locale: Locale) {
1512
const payload = await getPayload({ config: configPromise })
1613

1714
const global = await payload.findGlobal({
@@ -27,6 +24,6 @@ async function getGlobal(slug: Global, depth = 0) {
2724
* Returns a unstable_cache function mapped with the cache tag for the slug
2825
*/
2926
export const getCachedGlobal = (slug: Global, depth = 0) =>
30-
unstable_cache(async () => getGlobal(slug, depth), [slug], {
27+
unstable_cache(async (locale: Locale) => getGlobal(slug, depth, locale), [slug], {
3128
tags: [`global_${slug}`],
3229
})

0 commit comments

Comments
 (0)