@wpnuxt/core 1.0.0-edge.7 → 1.0.0-edge.9

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@wpnuxt/core",
3
- "version": "1.0.0-edge.7",
3
+ "version": "1.0.0-edge.9",
4
4
  "configKey": "wpNuxt",
5
5
  "nuxt": ">=3.1.0",
6
6
  "builder": {
package/dist/module.mjs CHANGED
@@ -7,7 +7,7 @@ import { upperFirst } from 'scule';
7
7
  import { parse } from 'graphql';
8
8
 
9
9
  const name = "@wpnuxt/core";
10
- const version = "1.0.0-edge.7";
10
+ const version = "1.0.0-edge.9";
11
11
 
12
12
  const loggerRef = ref();
13
13
  const initLogger = (logLevel) => {
@@ -225,12 +225,12 @@ const module = defineNuxtModule({
225
225
  const userQueryPathExists = existsSync(userQueryPath);
226
226
  cpSync(resolveRuntimeModule("./queries/"), queryOutputPath, { recursive: true });
227
227
  if (hasNuxtModule("@wpnuxt/blocks")) {
228
- logger.debug("Loading @wpnuxt/blocks");
229
228
  for (const m of nuxt.options._installedModules) {
230
229
  if (m.meta.name === "@wpnuxt/blocks" && m.entryPath) {
230
+ logger.debug("Loading queries from @wpnuxt/blocks");
231
231
  let blocksQueriesPath;
232
- if (m.entryPath.startsWith("../src/module")) {
233
- blocksQueriesPath = join(nuxt.options.rootDir, "../src/runtime/queries/");
232
+ if (m.entryPath.startsWith("../")) {
233
+ blocksQueriesPath = join(nuxt.options.rootDir, "../", m.entryPath, "./runtime/queries/");
234
234
  } else {
235
235
  blocksQueriesPath = join("./node_modules", m.entryPath, "dist/runtime/queries/");
236
236
  }
@@ -239,6 +239,12 @@ const module = defineNuxtModule({
239
239
  }
240
240
  } else {
241
241
  logger.debug("Tip: Install the @wpnuxt/blocks module if you want to render Gutenberg blocks with separate vue components");
242
+ addTemplate({
243
+ write: true,
244
+ filename: "wpnuxt/blocks.mjs",
245
+ getContents: () => `export { }`
246
+ });
247
+ nuxt.options.alias["#wpnuxt/blocks"] = resolve(nuxt.options.buildDir, "wpnuxt/blocks");
242
248
  }
243
249
  if (userQueryPathExists) {
244
250
  logger.debug("Extending queries:", userQueryPath);
@@ -13,5 +13,5 @@ const wpDark = props.wpColor ? props.wpColor : 'white'
13
13
  </template>
14
14
 
15
15
  <style scoped>
16
- .wpnuxt-logo{display:none;font-size:1.5rem;font-weight:700;line-height:2rem}@media (min-width:640px){.wpnuxt-logo{display:inline-flex}}.wpnuxt-logo-wp{color:v-bind(wpLight);font-family:ui-serif,Times,serif}html.dark .wpnuxt-logo-wp{color:v-bind(wpDark);font-family:ui-serif,Times,serif}.wpnuxt-logo-nuxt{margin-top:-1px;--tw-text-opacity:1;color:rgb(186 175 78/var(--tw-text-opacity))}
16
+ .wpnuxt-logo{display:inline-flex;font-size:1.5rem;font-weight:700;line-height:2rem}.wpnuxt-logo-wp{color:v-bind(wpLight);font-family:ui-serif,Times,serif}html.dark .wpnuxt-logo-wp{color:v-bind(wpDark);font-family:ui-serif,Times,serif}.wpnuxt-logo-nuxt{margin-top:-1px;--tw-text-opacity:1;color:rgb(186 175 78/var(--tw-text-opacity))}
17
17
  </style>
@@ -12,9 +12,9 @@ const _usePrevNextPost = async (currentPostSlug) => {
12
12
  };
13
13
  const getAllPosts = async () => {
14
14
  const { data: allPosts } = await useWPContent("Posts", ["posts", "nodes"], false);
15
- if (allPosts.value) {
15
+ if (allPosts) {
16
16
  return {
17
- slugs: allPosts.value?.map((post) => {
17
+ slugs: allPosts?.map((post) => {
18
18
  if (post) return post.slug;
19
19
  else return null;
20
20
  })
@@ -1,3 +1,5 @@
1
- import { FetchError } from 'ofetch';
2
- import { type AsyncData } from '#app';
3
- export declare const useWPContent: <T>(queryName: string, nodes: string[], fixImagePaths: boolean, params?: T) => Promise<AsyncData<T, FetchError | null>>;
1
+ import type { FetchError } from 'ofetch';
2
+ export declare const useWPContent: <T>(queryName: string, nodes: string[], fixImagePaths: boolean, params?: T) => Promise<{
3
+ data: T;
4
+ error: import("vue").Ref<FetchError<any> | null>;
5
+ }>;
@@ -1,28 +1,23 @@
1
- import { FetchError } from "ofetch";
2
1
  import { getRelativeImagePath } from "../util/images.js";
3
- import { useFetch, useNuxtApp } from "#app";
4
2
  const _useWPContent = async (queryName, nodes, fixImagePaths, params) => {
5
- const nuxtApp = useNuxtApp();
6
- const cacheKey = `wp-${queryName}-${nodes}-${JSON.stringify(params)}`;
7
- return useFetch("/api/wpContent", {
3
+ const { data, error } = await $fetch("/api/wpContent", {
8
4
  method: "POST",
9
5
  body: {
10
6
  queryName,
11
7
  params
12
- },
13
- key: cacheKey,
14
- transform(data) {
15
- const transformedData = findData(data.data, nodes);
16
- if (fixImagePaths && transformedData?.featuredImage?.node?.sourceUrl) {
17
- transformedData.featuredImage.node.relativePath = getRelativeImagePath(transformedData.featuredImage.node.sourceUrl);
18
- }
19
- if (transformedData) return transformedData;
20
- throw new FetchError("No data found");
21
- },
22
- getCachedData(key) {
23
- return nuxtApp.payload.data[key] || nuxtApp.static.data[key];
24
8
  }
25
9
  });
10
+ return {
11
+ data: transformData(data, nodes, fixImagePaths),
12
+ error
13
+ };
14
+ };
15
+ const transformData = (data, nodes, fixImagePaths) => {
16
+ const transformedData = findData(data, nodes);
17
+ if (fixImagePaths && transformedData?.featuredImage?.node?.sourceUrl) {
18
+ transformedData.featuredImage.node.relativePath = getRelativeImagePath(transformedData.featuredImage.node.sourceUrl);
19
+ }
20
+ return transformedData;
26
21
  };
27
22
  const findData = (data, nodes) => {
28
23
  if (nodes.length === 0) return data;
@@ -0,0 +1,3 @@
1
+ fragment NodeWithContentEditor on NodeWithContentEditor {
2
+ content
3
+ }
@@ -1,10 +1,11 @@
1
1
  #import '~/.queries/fragments/ContentNode.fragment.gql';
2
2
  #import '~/.queries/fragments/NodeWithFeaturedImage.fragment.gql';
3
+ #import '~/.queries/fragments/NodeWithContentEditor.fragment.gql';
3
4
 
4
5
  fragment Page on Page {
5
6
  ...ContentNode
6
7
  ...NodeWithFeaturedImage
7
- content
8
+ ...NodeWithContentEditor
8
9
  isFrontPage
9
10
  isPostsPage
10
11
  isPreview
@@ -1,11 +1,12 @@
1
1
  #import "~/.queries/fragments/NodeWithExcerpt.fragment.gql";
2
2
  #import '~/.queries/fragments/ContentNode.fragment.gql';
3
3
  #import '~/.queries/fragments/NodeWithFeaturedImage.fragment.gql';
4
+ #import '~/.queries/fragments/NodeWithContentEditor.fragment.gql';
4
5
 
5
6
  fragment Post on Post {
6
7
  ...NodeWithExcerpt
7
8
  ...ContentNode
8
9
  ...NodeWithFeaturedImage
9
- content
10
+ ...NodeWithContentEditor
10
11
  title
11
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wpnuxt/core",
3
- "version": "1.0.0-edge.7",
3
+ "version": "1.0.0-edge.9",
4
4
  "description": "WPNuxt",
5
5
  "repository": {
6
6
  "type": "git",
@@ -72,7 +72,7 @@
72
72
  "@nuxt/test-utils": "^3.14.1",
73
73
  "@rollup/rollup-linux-arm64-gnu": "^4.20.0",
74
74
  "@rollup/rollup-linux-arm64-musl": "^4.20.0",
75
- "@types/node": "22.3.0",
75
+ "@types/node": "22.4.1",
76
76
  "@vitest/coverage-v8": "^2.0.5",
77
77
  "@vue/test-utils": "^2.4.6",
78
78
  "@wordpress/env": "^10.5.0",