@wpnuxt/core 2.0.0-alpha.3 → 2.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wpnuxt",
3
3
  "configKey": "wpNuxt",
4
- "version": "2.0.0-alpha.2",
4
+ "version": "2.0.0-alpha.3",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,9 +1,27 @@
1
1
  import { getRelativeImagePath } from "../util/images.js";
2
2
  import { computed, useAsyncGraphqlQuery } from "#imports";
3
+ function defaultGetCachedData(key, nuxtApp, ctx) {
4
+ if (nuxtApp.isHydrating) {
5
+ return nuxtApp.payload.data[key];
6
+ }
7
+ if (ctx.cause === "refresh:manual" || ctx.cause === "refresh:hook") {
8
+ return void 0;
9
+ }
10
+ return nuxtApp.payload.data[key] ?? nuxtApp.static.data[key];
11
+ }
3
12
  export const useWPContent = (queryName, nodes, fixImagePaths, params, options) => {
13
+ const { clientCache, cacheKey, getCachedData: userGetCachedData, ...restOptions } = options ?? {};
14
+ const graphqlCaching = clientCache === false ? { client: false } : restOptions.graphqlCaching ?? { client: true };
15
+ const paramsKey = params ? JSON.stringify(params) : "{}";
16
+ const baseKey = `wpnuxt-${String(queryName)}-${paramsKey}`;
17
+ const finalKey = cacheKey ? `${baseKey}-${cacheKey}` : baseKey;
18
+ const effectiveGetCachedData = userGetCachedData ?? (clientCache === false ? () => void 0 : defaultGetCachedData);
4
19
  const mergedOptions = {
5
- graphqlCaching: { client: true },
6
- ...options
20
+ ...restOptions,
21
+ graphqlCaching,
22
+ // Explicit key ensures consistent cache lookups
23
+ key: finalKey,
24
+ getCachedData: effectiveGetCachedData
7
25
  };
8
26
  const { data, pending, refresh, execute, clear, error, status } = useAsyncGraphqlQuery(
9
27
  queryName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wpnuxt/core",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.4",
4
4
  "description": "Nuxt module for WordPress integration via GraphQL (WPGraphQL)",
5
5
  "keywords": [
6
6
  "nuxt",