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

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.8",
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.8";
11
11
 
12
12
  const loggerRef = ref();
13
13
  const initLogger = (logLevel) => {
@@ -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;
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.8",
4
4
  "description": "WPNuxt",
5
5
  "repository": {
6
6
  "type": "git",