@storyblok/nuxt 7.1.1 → 7.1.2
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,8 +1,6 @@
|
|
|
1
1
|
import type { ISbStoriesParams, ISbStoryData, StoryblokBridgeConfigV2 } from '@storyblok/vue';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export declare const useAsyncStoryblok: (url: string, apiOptions?: ISbStoriesParams, bridgeOptions?: StoryblokBridgeConfigV2) => Promise<StoryblokAsyncResult>;
|
|
8
|
-
export {};
|
|
2
|
+
export declare const useAsyncStoryblok: (url: string, apiOptions?: ISbStoriesParams, bridgeOptions?: StoryblokBridgeConfigV2) => Promise<import("vue").Ref<ISbStoryData<import("storyblok-js-client").ISbComponentType<string> & {
|
|
3
|
+
[index: string]: any;
|
|
4
|
+
}>, ISbStoryData<import("storyblok-js-client").ISbComponentType<string> & {
|
|
5
|
+
[index: string]: any;
|
|
6
|
+
}>>>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { useStoryblokApi, useStoryblokBridge } from "@storyblok/vue";
|
|
2
|
-
import { onMounted,
|
|
2
|
+
import { onMounted, useAsyncData, useState } from "#imports";
|
|
3
3
|
export const useAsyncStoryblok = async (url, apiOptions = {}, bridgeOptions = {}) => {
|
|
4
4
|
const storyblokApiInstance = useStoryblokApi();
|
|
5
5
|
const uniqueKey = `${JSON.stringify(apiOptions)}${url}`;
|
|
6
6
|
const story = useState(`${uniqueKey}-state`);
|
|
7
|
-
const error = useState(`${uniqueKey}-error`);
|
|
8
7
|
onMounted(() => {
|
|
9
8
|
if (story.value && story.value.id) {
|
|
10
9
|
useStoryblokBridge(
|
|
@@ -15,43 +14,15 @@ export const useAsyncStoryblok = async (url, apiOptions = {}, bridgeOptions = {}
|
|
|
15
14
|
}
|
|
16
15
|
});
|
|
17
16
|
if (!story.value) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
story.value = data.value?.data.story;
|
|
27
|
-
error.value = null;
|
|
28
|
-
}
|
|
29
|
-
} catch (err) {
|
|
30
|
-
if (typeof err === "object" && err !== null && "status" in err && "response" in err) {
|
|
31
|
-
error.value = {
|
|
32
|
-
status: err.status || err.response?.status,
|
|
33
|
-
response: err.message || err.response?.statusText
|
|
34
|
-
};
|
|
35
|
-
} else {
|
|
36
|
-
error.value = {
|
|
37
|
-
status: void 0,
|
|
38
|
-
response: "An unknown error occurred"
|
|
39
|
-
};
|
|
40
|
-
}
|
|
17
|
+
const { data } = await useAsyncData(uniqueKey, () => {
|
|
18
|
+
return storyblokApiInstance.get(
|
|
19
|
+
`cdn/stories/${url}`,
|
|
20
|
+
apiOptions
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
if (data) {
|
|
24
|
+
story.value = data.value?.data.story;
|
|
41
25
|
}
|
|
42
26
|
}
|
|
43
|
-
return
|
|
44
|
-
get value() {
|
|
45
|
-
return story.value;
|
|
46
|
-
},
|
|
47
|
-
set value(newValue) {
|
|
48
|
-
story.value = newValue;
|
|
49
|
-
},
|
|
50
|
-
get status() {
|
|
51
|
-
return error.value?.status;
|
|
52
|
-
},
|
|
53
|
-
get response() {
|
|
54
|
-
return error.value?.response;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
27
|
+
return story;
|
|
57
28
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.1.
|
|
4
|
+
"version": "7.1.2",
|
|
5
5
|
"description": "Storyblok Nuxt module",
|
|
6
6
|
"homepage": "https://github.com/storyblok/monoblok/tree/main/packages/nuxt#readme",
|
|
7
7
|
"repository": {
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"@nuxt/schema": "^3.15.4",
|
|
37
37
|
"@nuxt/test-utils": "^3.15.4",
|
|
38
38
|
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
39
|
-
"@storyblok/eslint-config": "^0.3.0",
|
|
40
39
|
"@types/node": "^22.15.18",
|
|
41
40
|
"cypress": "^14.3.3",
|
|
42
41
|
"eslint": "^9.26.0",
|
|
@@ -45,7 +44,8 @@
|
|
|
45
44
|
"eslint-plugin-vue": "^9.32.0",
|
|
46
45
|
"nuxt": "^3.15.4",
|
|
47
46
|
"prettier": "^3.4.2",
|
|
48
|
-
"start-server-and-test": "^2.0.11"
|
|
47
|
+
"start-server-and-test": "^2.0.11",
|
|
48
|
+
"@storyblok/eslint-config": "0.3.0"
|
|
49
49
|
},
|
|
50
50
|
"release": {
|
|
51
51
|
"branches": [
|