Skip to content

Commit

Permalink
fix: make useConfig() work for vike-solid hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Aug 20, 2024
1 parent 52eea42 commit 2d2ce2b
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions vike-solid/utils/callCumulativeHooks.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
export async function callCumulativeHooks(values: undefined | unknown[], pageContext: unknown): Promise<unknown[]> {
if (!values) return [];
export { callCumulativeHooks }

import { providePageContext } from 'vike/getPageContext'

async function callCumulativeHooks(
values: undefined | unknown[],
pageContext: Record<string, any>,
): Promise<unknown[]> {
if (!values) return []
const valuesPromises = values.map((val) => {
if (typeof val === "function") {
if (typeof val === 'function') {
providePageContext(pageContext)
// Hook
return val(pageContext);
return val(pageContext)
} else {
// Plain value
return val;
return val
}
});
const valuesResolved = await Promise.all(valuesPromises);
return valuesResolved;
})
const valuesResolved = await Promise.all(valuesPromises)
return valuesResolved
}

0 comments on commit 2d2ce2b

Please sign in to comment.