@@ -8,8 +8,7 @@ import { getLocale } from 'next-intl/server'
88import { decodeSlugs } from '@/lib/helpers/getFullUrl'
99import { Flags } from '@/sanity/helpers/datasetHelpers'
1010import { getNameFromIso } from '@/sanity/helpers/localization'
11- import { IS_FETCH_OPTIMIZED , routeSanityFetch } from '@/sanity/lib/fetch'
12- import { optimizedFetch } from '@/sanity/lib/simpleFetch'
11+ import { routeSanityFetch } from '@/sanity/lib/fetch'
1312import { constructSanityMetadata , getPage } from '@/sanity/pages/utils'
1413import { menuQuery as globalMenuQuery } from '@/sanity/queries/menu'
1514import {
@@ -31,16 +30,11 @@ const NewsPage = dynamic(() => import('@/templates/news/News'))
3130const TopicPage = dynamic ( ( ) => import ( '@/templates/topic/TopicPage' ) )
3231const MagazineRoom = dynamic ( ( ) => import ( '@/templates/magazine/Magazineroom' ) )
3332
34- const getSanityFetch = ( isDraftMode : boolean ) =>
35- isDraftMode || ! IS_FETCH_OPTIMIZED ? routeSanityFetch : optimizedFetch
36-
3733export async function generateMetadata ( {
3834 params,
3935} : PageProps < '/[locale]/[...slug]' > ) : Promise < Metadata > {
4036 //array, separated by /. e.g. [news, last slug]
4137 const { slug : encodedSlug , locale } = await params
42- const { isEnabled : isDraftMode } = await draftMode ( )
43- const sanityFetch = getSanityFetch ( isDraftMode )
4438 const slug = decodeSlugs ( encodedSlug ) as string [ ]
4539
4640 const sanityLang = getNameFromIso ( locale )
@@ -65,7 +59,7 @@ export async function generateMetadata({
6559 query = magazineroomMetaQuery
6660 }
6761
68- const { data : metaData } : { data : any } = await sanityFetch ( {
62+ const { data : metaData } : { data : any } = await routeSanityFetch ( {
6963 query,
7064 params : {
7165 lang : sanityLang ,
@@ -87,10 +81,9 @@ export default async function Page({ params, searchParams }: Props) {
8781 /* const isInPresentationToolContext =
8882 (await cookies()).get('preview-fetch-dest')?.value === 'iframe' */
8983 const { isEnabled : isDraftMode } = await draftMode ( )
90- const sanityFetch = getSanityFetch ( isDraftMode )
9184 let pageContent = null
9285 const [ siteMenuResult , pageResults ] = await Promise . all ( [
93- sanityFetch ( {
86+ routeSanityFetch ( {
9487 query : Flags . HAS_FANCY_MENU ? globalMenuQuery : simpleMenuQuery ,
9588 params : {
9689 lang : getNameFromIso ( locale ) ?? 'en_GB' ,
@@ -101,7 +94,7 @@ export default async function Page({ params, searchParams }: Props) {
10194 slug : decodeSlugs ( slug ) ,
10295 locale,
10396 searchParams : resolvedSearchParams ,
104- fetch : sanityFetch ,
97+ fetch : routeSanityFetch ,
10598 } ) ,
10699 ] )
107100 pageContent = pageResults
0 commit comments