@@ -2,6 +2,7 @@ import { hash } from 'ohash'
22import { useRuntimeConfig } from '#app'
33import type { NavItem , QueryBuilder , QueryBuilderParams } from '../types'
44import { encodeQueryParams } from '../utils/query'
5+ import { jsonStringify } from '../utils/json'
56import { addPrerenderPath , shouldUseClientDB , withContentBase } from './utils'
67
78export const fetchContentNavigation = async ( queryBuilder ?: QueryBuilder | QueryBuilderParams ) : Promise < Array < NavItem > > => {
@@ -21,7 +22,9 @@ export const fetchContentNavigation = async (queryBuilder?: QueryBuilder | Query
2122 }
2223 }
2324
24- const apiPath = withContentBase ( `/navigation/${ process . dev ? '_' : `${ hash ( params ) } .${ content . integrity } ` } /${ encodeQueryParams ( params ) } .json` )
25+ const apiPath = content . experimental . stripQueryParameters
26+ ? withContentBase ( `/navigation/${ process . dev ? '_' : `${ hash ( params ) } .${ content . integrity } ` } /${ encodeQueryParams ( params ) } .json` )
27+ : withContentBase ( process . dev ? `/navigation/${ hash ( params ) } ` : `/navigation/${ hash ( params ) } .${ content . integrity } .json` )
2528
2629 // Add `prefetch` to `<head>` in production
2730 if ( ! process . dev && process . server ) {
@@ -33,7 +36,16 @@ export const fetchContentNavigation = async (queryBuilder?: QueryBuilder | Query
3336 return generateNavigation ( params )
3437 }
3538
36- const data = await $fetch < NavItem [ ] > ( apiPath , { method : 'GET' , responseType : 'json' } )
39+ const data = await $fetch < NavItem [ ] > ( apiPath as any , {
40+ method : 'GET' ,
41+ responseType : 'json' ,
42+ params : content . experimental . stripQueryParameters
43+ ? undefined
44+ : {
45+ _params : jsonStringify ( params ) ,
46+ previewToken : useCookie ( 'previewToken' ) . value
47+ }
48+ } )
3749
3850 // On SSG, all url are redirected to `404.html` when not found, so we need to check the content type
3951 // to know if the response is a valid JSON or not
0 commit comments