@storyblok/nuxt 8.1.4 → 8.2.1
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.d.mts +7 -20
- package/dist/module.d.ts +7 -20
- package/dist/module.json +1 -1
- package/dist/module.mjs +13 -2
- package/dist/runtime/plugin.js +5 -1
- package/dist/runtime/server/index.d.ts +2 -0
- package/dist/runtime/server/index.js +19 -0
- package/package.json +8 -7
package/dist/module.d.mts
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { AsyncDataOptions, AsyncData, NuxtError } from 'nuxt/app';
|
|
3
|
-
import { ISbResult, ISbStoriesParams, StoryblokBridgeConfigV2 } from '@storyblok/vue';
|
|
4
|
-
import { ComputedRef } from 'vue';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
* Options for the useAsyncStoryblok composable.
|
|
8
|
-
* Extends Nuxt's AsyncDataOptions with Storyblok-specific configuration.
|
|
9
|
-
*/
|
|
10
|
-
interface UseAsyncStoryblokOptions extends AsyncDataOptions<ISbResult> {
|
|
11
|
-
/** Storyblok API parameters for fetching stories */
|
|
12
|
-
api: ISbStoriesParams;
|
|
13
|
-
/** Storyblok Bridge configuration for live preview */
|
|
14
|
-
bridge: StoryblokBridgeConfigV2;
|
|
15
|
-
}
|
|
16
|
-
interface UseAsyncStoryblokResult extends AsyncData<ISbResult, NuxtError<unknown>> {
|
|
17
|
-
story: ComputedRef<ISbResult['data']['story']>;
|
|
18
|
-
}
|
|
19
|
-
interface ModuleOptions {
|
|
20
|
-
accessToken: string;
|
|
3
|
+
interface PublicModuleOptions {
|
|
21
4
|
enableSudoMode: boolean;
|
|
22
5
|
usePlugin: boolean;
|
|
23
6
|
bridge: boolean;
|
|
24
7
|
devtools: boolean;
|
|
25
8
|
apiOptions: any;
|
|
26
9
|
componentsDir: string;
|
|
10
|
+
enableServerClient: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface AllModuleOptions extends PublicModuleOptions {
|
|
13
|
+
accessToken: string;
|
|
27
14
|
}
|
|
28
15
|
|
|
29
|
-
declare const _default: _nuxt_schema.NuxtModule<
|
|
16
|
+
declare const _default: _nuxt_schema.NuxtModule<AllModuleOptions, AllModuleOptions, false>;
|
|
30
17
|
|
|
31
18
|
export { _default as default };
|
|
32
|
-
export type {
|
|
19
|
+
export type { AllModuleOptions, PublicModuleOptions };
|
package/dist/module.d.ts
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { AsyncDataOptions, AsyncData, NuxtError } from 'nuxt/app';
|
|
3
|
-
import { ISbResult, ISbStoriesParams, StoryblokBridgeConfigV2 } from '@storyblok/vue';
|
|
4
|
-
import { ComputedRef } from 'vue';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
* Options for the useAsyncStoryblok composable.
|
|
8
|
-
* Extends Nuxt's AsyncDataOptions with Storyblok-specific configuration.
|
|
9
|
-
*/
|
|
10
|
-
interface UseAsyncStoryblokOptions extends AsyncDataOptions<ISbResult> {
|
|
11
|
-
/** Storyblok API parameters for fetching stories */
|
|
12
|
-
api: ISbStoriesParams;
|
|
13
|
-
/** Storyblok Bridge configuration for live preview */
|
|
14
|
-
bridge: StoryblokBridgeConfigV2;
|
|
15
|
-
}
|
|
16
|
-
interface UseAsyncStoryblokResult extends AsyncData<ISbResult, NuxtError<unknown>> {
|
|
17
|
-
story: ComputedRef<ISbResult['data']['story']>;
|
|
18
|
-
}
|
|
19
|
-
interface ModuleOptions {
|
|
20
|
-
accessToken: string;
|
|
3
|
+
interface PublicModuleOptions {
|
|
21
4
|
enableSudoMode: boolean;
|
|
22
5
|
usePlugin: boolean;
|
|
23
6
|
bridge: boolean;
|
|
24
7
|
devtools: boolean;
|
|
25
8
|
apiOptions: any;
|
|
26
9
|
componentsDir: string;
|
|
10
|
+
enableServerClient: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface AllModuleOptions extends PublicModuleOptions {
|
|
13
|
+
accessToken: string;
|
|
27
14
|
}
|
|
28
15
|
|
|
29
|
-
declare const _default: _nuxt_schema.NuxtModule<
|
|
16
|
+
declare const _default: _nuxt_schema.NuxtModule<AllModuleOptions, AllModuleOptions, false>;
|
|
30
17
|
|
|
31
18
|
export { _default as default };
|
|
32
|
-
export type {
|
|
19
|
+
export type { AllModuleOptions, PublicModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -13,7 +13,8 @@ const module = defineNuxtModule({
|
|
|
13
13
|
bridge: true,
|
|
14
14
|
devtools: false,
|
|
15
15
|
componentsDir: "~/storyblok",
|
|
16
|
-
apiOptions: {}
|
|
16
|
+
apiOptions: {},
|
|
17
|
+
enableServerClient: false
|
|
17
18
|
},
|
|
18
19
|
setup(options, nuxt) {
|
|
19
20
|
const resolver = createResolver(import.meta.url);
|
|
@@ -30,11 +31,21 @@ const module = defineNuxtModule({
|
|
|
30
31
|
nuxt.options.build.transpile.push("@storyblok/nuxt");
|
|
31
32
|
nuxt.options.build.transpile.push("@storyblok/vue");
|
|
32
33
|
addImportsDir(resolver.resolve("./runtime/composables"));
|
|
33
|
-
|
|
34
|
+
if (options.enableServerClient) {
|
|
35
|
+
const { accessToken, ...publicOptions } = options;
|
|
36
|
+
nuxt.options.runtimeConfig.storyblok = { accessToken };
|
|
37
|
+
nuxt.options.runtimeConfig.public.storyblok = publicOptions;
|
|
38
|
+
} else {
|
|
39
|
+
nuxt.options.runtimeConfig.public.storyblok = options;
|
|
40
|
+
}
|
|
34
41
|
const enablePluginCondition = options.usePlugin === true && options.enableSudoMode === false;
|
|
35
42
|
if (enablePluginCondition) {
|
|
36
43
|
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
37
44
|
}
|
|
45
|
+
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
46
|
+
nitroConfig.alias = nitroConfig.alias || {};
|
|
47
|
+
nitroConfig.alias["#storyblok/server"] = resolver.resolve("./runtime/server");
|
|
48
|
+
});
|
|
38
49
|
const names = [
|
|
39
50
|
"useStoryblok",
|
|
40
51
|
"useStoryblokApi",
|
package/dist/runtime/plugin.js
CHANGED
|
@@ -3,5 +3,9 @@ import { defineNuxtPlugin, useRuntimeConfig } from "#app";
|
|
|
3
3
|
export default defineNuxtPlugin(({ vueApp }) => {
|
|
4
4
|
let { storyblok } = useRuntimeConfig().public;
|
|
5
5
|
storyblok = JSON.parse(JSON.stringify(storyblok));
|
|
6
|
-
|
|
6
|
+
if (storyblok.enableServerClient) {
|
|
7
|
+
vueApp.use(StoryblokVue, { ...storyblok });
|
|
8
|
+
} else {
|
|
9
|
+
vueApp.use(StoryblokVue, { ...storyblok, use: [apiPlugin] });
|
|
10
|
+
}
|
|
7
11
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StoryblokClient } from "@storyblok/vue";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
export const serverStoryblokClient = (event) => {
|
|
4
|
+
const config = useRuntimeConfig();
|
|
5
|
+
const { accessToken } = config.storyblok;
|
|
6
|
+
const { apiOptions = {} } = config.public.storyblok;
|
|
7
|
+
if (!accessToken) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
`Storyblok access token is not configured. Make sure to set storyblok.accessToken in your nuxt.config.ts and enable storyblok.enableServerClient = true to use the server-side client.`
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
if (!event.context._storyblokClient) {
|
|
13
|
+
event.context._storyblokClient = new StoryblokClient({
|
|
14
|
+
accessToken,
|
|
15
|
+
...apiOptions
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return event.context._storyblokClient;
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.1
|
|
4
|
+
"version": "8.2.1",
|
|
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.
|
|
28
|
+
"@storyblok/vue": "9.4.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@cypress/vite-dev-server": "^6.0.3",
|
|
@@ -69,15 +69,16 @@
|
|
|
69
69
|
"test:types": "tsc --noEmit --skipLibCheck",
|
|
70
70
|
"dev": "nuxi dev playground",
|
|
71
71
|
"dev:build": "nuxi build playground",
|
|
72
|
-
"dev:preview": "nuxi preview playground",
|
|
72
|
+
"dev:preview": "nuxi preview playground --port 3100",
|
|
73
|
+
"dev:e2e": "nuxi dev playground-e2e --port 3100",
|
|
73
74
|
"prepare:playground": "nuxi prepare playground",
|
|
74
75
|
"dev:prepare": "nuxt-module-build build --stub && nuxi prepare playground",
|
|
75
76
|
"cy:open": "cypress open",
|
|
76
77
|
"cy:run": "cypress run",
|
|
77
|
-
"test:e2e": "start-server-and-test dev http://localhost:
|
|
78
|
-
"test:e2e-watch": "start-server-and-test dev http://localhost:
|
|
79
|
-
"pretest:e2e-static": "nuxi generate playground",
|
|
80
|
-
"test:e2e-static": "start-server-and-test dev:preview http://localhost:
|
|
78
|
+
"test:e2e": "start-server-and-test dev:e2e http://localhost:3100 cy:run",
|
|
79
|
+
"test:e2e-watch": "start-server-and-test dev:e2e http://localhost:3100 cy:open",
|
|
80
|
+
"pretest:e2e-static": "nuxi generate playground-e2e",
|
|
81
|
+
"test:e2e-static": "start-server-and-test dev:preview http://localhost:3100 cy:run",
|
|
81
82
|
"lint": "eslint .",
|
|
82
83
|
"lint:fix": "eslint . --fix",
|
|
83
84
|
"test": "pnpm run test:e2e"
|