@@ -2,6 +2,7 @@ import { hash } from 'ohash'
2
2
import { useRuntimeConfig } from '#app'
3
3
import type { NavItem , QueryBuilder , QueryBuilderParams } from '../types'
4
4
import { encodeQueryParams } from '../utils/query'
5
+ import { jsonStringify } from '../utils/json'
5
6
import { addPrerenderPath , shouldUseClientDB , withContentBase } from './utils'
6
7
7
8
export const fetchContentNavigation = async ( queryBuilder ?: QueryBuilder | QueryBuilderParams ) : Promise < Array < NavItem > > => {
@@ -21,7 +22,9 @@ export const fetchContentNavigation = async (queryBuilder?: QueryBuilder | Query
21
22
}
22
23
}
23
24
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` )
25
28
26
29
// Add `prefetch` to `<head>` in production
27
30
if ( ! process . dev && process . server ) {
@@ -33,7 +36,16 @@ export const fetchContentNavigation = async (queryBuilder?: QueryBuilder | Query
33
36
return generateNavigation ( params )
34
37
}
35
38
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
+ } )
37
49
38
50
// On SSG, all url are redirected to `404.html` when not found, so we need to check the content type
39
51
// to know if the response is a valid JSON or not
0 commit comments