@storyblok/nuxt 7.1.1 → 7.1.3

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": "@storyblok/nuxt",
3
3
  "configKey": "storyblok",
4
- "version": "7.1.1",
4
+ "version": "7.1.3",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "unknown"
@@ -1,8 +1,6 @@
1
1
  import type { ISbStoriesParams, ISbStoryData, StoryblokBridgeConfigV2 } from '@storyblok/vue';
2
- interface StoryblokAsyncResult<T = ISbStoryData> {
3
- value: T;
4
- status?: number;
5
- response?: string;
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, reactive, useAsyncData, useState } from "#imports";
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
- try {
19
- const { data } = await useAsyncData(uniqueKey, () => {
20
- return storyblokApiInstance.get(
21
- `cdn/stories/${url}`,
22
- apiOptions
23
- );
24
- });
25
- if (data) {
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 reactive({
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.1",
4
+ "version": "7.1.3",
5
5
  "description": "Storyblok Nuxt module",
6
6
  "homepage": "https://github.com/storyblok/monoblok/tree/main/packages/nuxt#readme",
7
7
  "repository": {
@@ -25,7 +25,7 @@
25
25
  "dist"
26
26
  ],
27
27
  "dependencies": {
28
- "@storyblok/vue": "9.1.1"
28
+ "@storyblok/vue": "9.1.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@cypress/vite-dev-server": "^6.0.3",
@@ -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": [
@@ -78,6 +78,7 @@
78
78
  "pretest:e2e-static": "nuxi generate playground",
79
79
  "test:e2e-static": "start-server-and-test dev:preview http://localhost:3000 cy:run",
80
80
  "lint": "eslint .",
81
- "lint:fix": "eslint . --fix"
81
+ "lint:fix": "eslint . --fix",
82
+ "test": "pnpm run test:e2e"
82
83
  }
83
84
  }