@storyblok/nuxt 5.1.0 → 5.3.0

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/README.md CHANGED
@@ -76,7 +76,9 @@ export default defineNuxtConfig({
76
76
 
77
77
  #### Options
78
78
 
79
- When you initialize the module, you can pass all [_@storyblok/vue_ options](https://github.com/storyblok/storyblok-vue#storyblok-api) plus a `useApiClient` option. For spaces created in the United States, you have to set the `region` parameter accordingly `{ apiOptions: { region: 'us' } }`.
79
+ When you initialize the module, you can pass all [_@storyblok/vue_ options](https://github.com/storyblok/storyblok-vue#storyblok-api) plus a `bridge` option explained in our [JS SDK Storyblok bridge section](https://github.com/storyblok/storyblok-js#storyblok-bridge).
80
+
81
+ > Note: For spaces created in the United States, you have to set the `region` parameter accordingly `{ apiOptions: { region: 'us' } }`.
80
82
 
81
83
  ```js
82
84
  // Defaults
@@ -85,7 +87,6 @@ When you initialize the module, you can pass all [_@storyblok/vue_ options](http
85
87
  accessToken: "<your-access-token>",
86
88
  bridge: true,
87
89
  apiOptions: {}, // storyblok-js-client options
88
- useApiClient: true
89
90
  }
90
91
  }]
91
92
  ```
@@ -94,9 +95,13 @@ When you initialize the module, you can pass all [_@storyblok/vue_ options](http
94
95
 
95
96
  ### 1. Creating and linking your components to Storyblok Visual Editor
96
97
 
97
- To link your Vue components to their equivalent you created in Storyblok:
98
+ To link your Vue components to the equivalent one in your Storyblok space:
99
+
100
+ - First, you need to load them globally adding them to the `~/storyblok` directory. It's important to name them with Pascal case in your code `ExampleComponent.vue` and with a hyphen inside your Storyblok space `example-component`, so they will be imported automatically.
101
+
102
+ Otherwise, you can set another directory and load them manually (for example, by [using a Nuxt plugin](https://stackoverflow.com/questions/43040692/global-components-in-vue-nuxt)).
98
103
 
99
- - First, you need to load them globally. You can just place them on the `~/storyblok` directory and will be discovered automagically, otherwise you set another directory can load them manually (for example, by [using a Nuxt plugin](https://stackoverflow.com/questions/43040692/global-components-in-vue-nuxt)).
104
+ > Take into account that if you name a component inside the `storyblok` folder the same as another in the `components` folder, it won't work properly. Tip: Keep the components in your Nuxt project with different names.
100
105
 
101
106
  - For each components, use the `v-editable` directive on its root element, passing the `blok` property that they receive:
102
107
 
@@ -118,6 +123,8 @@ To link your Vue components to their equivalent you created in Storyblok:
118
123
 
119
124
  The simplest way is by using the `useAsyncStoryblok` one-liner composable (it's autoimported) and passing as a first parameter a name of your content page from Storyblok (in this case, our content page name is `vue`, by default you get a content page named `home`):
120
125
 
126
+ > If you want to know more about versioning `{ version: "draft" /* or "publish" */ }` then go to the section [Working with preview and/or production environments](#3-working-with-preview-andor-production-environments)
127
+
121
128
  ```html
122
129
  <script setup>
123
130
  const story = await useAsyncStoryblok("vue", { version: "draft" });
@@ -197,6 +204,16 @@ You can also set a **custom Schema and component resolver** by passing the optio
197
204
  </script>
198
205
  ```
199
206
 
207
+ ### 3. Working with preview and/or production environments
208
+
209
+ Remember that the bridge only works using `version: { 'draft' }` and the _Preview Access Token_.
210
+
211
+ For the production site, NOT used as a preview for content editors, `version: { 'published' }` and _Public Access Token_ should be used.
212
+
213
+ > If you're using production as a preview for marketeers and your public site, you will need a plugin to handle different .env variables, or versions using the _Preview Access Token_, checking if you are inside Storyblok or not. For example, something like `if (window.location.search.includes(_storyblok_tk[token]=<YOUR_TOKEN>)`.
214
+
215
+ Check the official docs on how to [access different content versions](https://www.storyblok.com/docs/guide/essentials/accessing-data#content-versions).
216
+
200
217
  ### API
201
218
 
202
219
  #### useAsyncStoryblok(slug, apiOptions, bridgeOptions)
package/dist/module.d.ts CHANGED
@@ -1,38 +1,11 @@
1
- import { defineNuxtModule, createResolver, addComponentsDir, addPlugin, addImports, addImportsDir } from '@nuxt/kit';
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
- var module = defineNuxtModule({
4
- meta: {
5
- name: "@storyblok/nuxt",
6
- configKey: "storyblok"
7
- },
8
- defaults: {
9
- usePlugin: true
10
- },
11
- setup(options, nuxt) {
12
- const resolver = createResolver(import.meta.url);
13
- nuxt.options.vite.optimizeDeps.include = nuxt.options.vite.optimizeDeps.include || [];
14
- nuxt.options.vite.optimizeDeps.include.push("@storyblok/nuxt");
15
- nuxt.options.vite.optimizeDeps.include.push("@storyblok/vue");
16
- addComponentsDir({ path: "~/storyblok", global: true, pathPrefix: false });
17
- nuxt.options.build.transpile.push(resolver.resolve("./runtime"));
18
- nuxt.options.build.transpile.push("@storyblok/nuxt");
19
- nuxt.options.build.transpile.push("@storyblok/vue");
20
- nuxt.options.runtimeConfig.public.storyblok = options;
21
- if (options.usePlugin !== false) {
22
- addPlugin(resolver.resolve("./runtime/plugin"));
23
- }
24
- const names = [
25
- "useStoryblok",
26
- "useStoryblokApi",
27
- "useStoryblokBridge",
28
- "renderRichText",
29
- "RichTextSchema"
30
- ];
31
- for (const name of names) {
32
- addImports({ name, as: name, from: "@storyblok/vue" });
33
- }
34
- addImportsDir(resolver.resolve("./runtime/composables"));
35
- }
36
- });
3
+ interface ModuleOptions {
4
+ accessToken: string;
5
+ usePlugin: boolean;
6
+ bridge: boolean;
7
+ apiOptions: any;
8
+ }
9
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
37
10
 
38
- export { module as default };
11
+ export { ModuleOptions, _default as default };
package/dist/module.mjs CHANGED
@@ -6,7 +6,10 @@ const module = defineNuxtModule({
6
6
  configKey: "storyblok"
7
7
  },
8
8
  defaults: {
9
- usePlugin: true
9
+ accessToken: "",
10
+ usePlugin: true,
11
+ bridge: true,
12
+ apiOptions: {}
10
13
  },
11
14
  setup(options, nuxt) {
12
15
  const resolver = createResolver(import.meta.url);
@@ -1,2 +1,2 @@
1
- declare var _default: any;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,6 +1,5 @@
1
1
  import { StoryblokVue, apiPlugin } from "@storyblok/vue";
2
2
  import { defineNuxtPlugin, useRuntimeConfig } from "#app";
3
-
4
3
  export default defineNuxtPlugin(({ vueApp }) => {
5
4
  let { storyblok } = useRuntimeConfig();
6
5
  storyblok = JSON.parse(JSON.stringify(storyblok));
package/dist/types.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
 
2
- import { } from './module'
2
+ import { ModuleOptions } from './module'
3
3
 
4
+ declare module '@nuxt/schema' {
5
+ interface NuxtConfig { ['storyblok']?: Partial<ModuleOptions> }
6
+ interface NuxtOptions { ['storyblok']?: ModuleOptions }
7
+ }
4
8
 
5
9
 
6
10
  export { default } from './module'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/nuxt",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "description": "Storyblok Nuxt module",
5
5
  "type": "module",
6
6
  "exports": {