-
-
Notifications
You must be signed in to change notification settings - Fork 427
Expand file tree
/
Copy pathfix.client.ts
More file actions
21 lines (20 loc) · 699 Bytes
/
fix.client.ts
File metadata and controls
21 lines (20 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export default defineNuxtPlugin({
enforce: 'pre',
setup(nuxtApp) {
// TODO: investigate why this is needed
nuxtApp.payload.data ||= {}
// When a _payload.json returns an ISR fallback (empty payload), data fetching composables
// with non-undefined defaults skip refetching during hydration. After hydration completes,
// refresh all async data so these composables (e.g. README, skills, package analysis) fetch
// fresh data.
if (
nuxtApp.isHydrating &&
nuxtApp.payload.serverRendered &&
!Object.keys(nuxtApp.payload.data).length
) {
nuxtApp.hooks.hookOnce('app:suspense:resolve', () => {
refreshNuxtData()
})
}
},
})