@storyblok/nuxt 5.1.0 → 5.2.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 +21 -4
- package/package.json +1 -1
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 `
|
|
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
|
|
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
|
-
|
|
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)
|