@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 +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/WPNuxtLogo.vue +1 -1
- package/dist/runtime/composables/usePrevNextPost.js +2 -2
- package/dist/runtime/composables/useWPContent.d.ts +5 -3
- package/dist/runtime/composables/useWPContent.js +12 -17
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -13,5 +13,5 @@ const wpDark = props.wpColor ? props.wpColor : 'white'
|
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
15
|
<style scoped>
|
|
16
|
-
.wpnuxt-logo{display:
|
|
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
|
|
15
|
+
if (allPosts) {
|
|
16
16
|
return {
|
|
17
|
-
slugs: allPosts
|
|
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
|
-
|
|
3
|
-
|
|
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
|
|
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;
|