@storyblok/nuxt 6.0.10 → 6.0.11

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
@@ -21,25 +21,19 @@
21
21
  </a>
22
22
  <a href="https://twitter.com/intent/follow?screen_name=storyblok">
23
23
  <img src="https://img.shields.io/badge/Follow-%40storyblok-09b3af?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
24
- </a><br/>
24
+ </a><br />
25
25
  <a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt">
26
26
  <img src="https://img.shields.io/badge/Try%20Storyblok-Free-09b3af?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
27
27
  </a>
28
28
  </p>
29
29
 
30
- ### Live Demo
30
+ ## Kickstart a new project
31
+ Are you eager to dive into coding? **[Follow these steps to kickstart a new project with Storyblok and Nuxt](https://www.storyblok.com/technologies#nuxt?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt)**, and get started in just a few minutes!
31
32
 
32
- If you are in a hurry, check out our official **[live demo](https://stackblitz.com/edit/nuxt-3-sdk-demo?file=pages/index.vue)** on Stackblitz.
33
+ ## Ultimate Tutorial
34
+ Are you looking for a hands-on, step-by-step tutorial? The **[Nuxt Ultimate Tutorial](https://www.storyblok.com/tp/storyblok-nuxt-ultimate-tutorial?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt)** has you covered! It provides comprehensive instructions on building a complete, multilingual website using Storyblok and Nuxt from start to finish.
33
35
 
34
- ## 🚀 Usage
35
-
36
- > **Note**
37
- > This module is for Nuxt 3. [Check out `@storyblok/nuxt-2` for Nuxt 2](https://github.com/storyblok/storyblok-nuxt-2).
38
-
39
- > **Important**
40
- > If you are first-time user of the Storyblok, read the [Getting Started](https://www.storyblok.com/docs/guide/getting-started?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt) guide to get a project ready in less than 5 minutes.
41
-
42
- ### Installation
36
+ ## Installation
43
37
 
44
38
  Install `@storyblok/nuxt`:
45
39
 
@@ -76,7 +70,7 @@ export default defineNuxtConfig({
76
70
  > **Warning**
77
71
  > This SDK uses the Fetch API under the hood. If your environment doesn't support it, you need to install a polyfill like [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch). More info on [storyblok-js-client docs](https://github.com/storyblok/storyblok-js-client#fetch-use-polyfill-if-needed---version-5).
78
72
 
79
- #### Options
73
+ ### Options
80
74
 
81
75
  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) and a `enableSudoMode` option to define your own plugin (see below).
82
76
 
@@ -95,7 +89,7 @@ When you initialize the module, you can pass all [_@storyblok/vue_ options](http
95
89
  }]
96
90
  ```
97
91
 
98
- #### Define your own plugin
92
+ ### Define your own plugin
99
93
 
100
94
  While the recommended approach covers most cases, there are specific instances where you may need to use the `enableSudoMode` option and disable our plugin, allowing you to incorporate your own.
101
95
 
@@ -136,7 +130,7 @@ export default defineNuxtPlugin(({ vueApp }) => {
136
130
  });
137
131
  ```
138
132
 
139
- #### Region parameter
133
+ ## Region parameter
140
134
 
141
135
  Possible values:
142
136
 
@@ -162,9 +156,9 @@ Full example for a space created in the US:
162
156
  > **Important**
163
157
  > For spaces created in the United States or China, the `region` parameter **must** be specified.
164
158
 
165
- ### Getting started
159
+ ## Getting started
166
160
 
167
- ### 1. Creating and linking your components to Storyblok Visual Editor
161
+ ### 1. Creating and linking your components to the Storyblok Visual Editor
168
162
 
169
163
  To link your Vue components to the equivalent one in your Storyblok space:
170
164
 
@@ -179,7 +173,7 @@ To link your Vue components to the equivalent one in your Storyblok space:
179
173
  "@storyblok/nuxt",
180
174
  {
181
175
  accessToken: "<your-access-token>",
182
- componentsDir: false,
176
+ componentsDir: '~/components',
183
177
  }
184
178
  ]
185
179
  ],
@@ -201,7 +195,7 @@ To link your Vue components to the equivalent one in your Storyblok space:
201
195
  - For each component, use the `v-editable` directive on its root element, passing the `blok` property that they receive:
202
196
 
203
197
  ```html
204
- <div v-editable="blok" / >
198
+ <div v-editable="blok"></div>
205
199
  ```
206
200
 
207
201
  - Finally, use `<StoryblokComponent>` which is available globally in the Nuxt app:
@@ -251,7 +245,7 @@ Which is the short-hand equivalent to using `useStoryblokApi` inside `useState`
251
245
  const story = useState();
252
246
  const storyblokApi = useStoryblokApi();
253
247
 
254
- const { data } = await storyblokApiInstance.get(
248
+ const { data } = await storyblokApi.get(
255
249
  `cdn/stories/vue`,
256
250
  {
257
251
  version: "draft"
@@ -275,7 +269,7 @@ Which is the short-hand equivalent to using `useStoryblokApi` inside `useState`
275
269
 
276
270
  > The `useState` is an SSR-friendly `ref` replacement. Its value will be preserved after server-side rendering (during client-side hydration).
277
271
 
278
- #### Rendering Rich Text
272
+ ## Rendering Rich Text
279
273
 
280
274
  You can easily render rich text by using the `renderRichText` function that comes with `@storyblok/nuxt` and a Vue computed property:
281
275
 
@@ -320,7 +314,7 @@ You can also set a **custom Schema and component resolver** by passing the optio
320
314
  </script>
321
315
  ```
322
316
 
323
- ### 3. Working with preview and/or production environments
317
+ ## 3. Working with preview and/or production environments
324
318
 
325
319
  Remember that the bridge only works using `version: 'draft'` and the _Preview Access Token_.
326
320
 
@@ -331,25 +325,62 @@ For the production site, NOT used as a preview for content editors, `version: 'p
331
325
 
332
326
  Check the official docs on how to [access different content versions](https://www.storyblok.com/docs/guide/essentials/accessing-data#content-versions).
333
327
 
334
- ### API
328
+ The recommended way to handle different content versions with Nuxt is by using environment variables in combination with [Nuxt runtime config](https://nuxt.com/docs/guide/going-further/runtime-config) to expose configuration and secrets within your application
329
+
330
+ In your `nuxt.config.ts`:
331
+
332
+ ```ts
333
+ export default defineNuxtConfig({
334
+ runtimeConfig: {
335
+ public: {
336
+ storyblokVersion: process.env.STORYBLOK_VERSION || "published"
337
+ }
338
+ }
339
+ });
340
+ ```
341
+
342
+ Then you can access the runtime config in your components:
343
+
344
+ ```ts
345
+ const config = useRuntimeConfig();
346
+
347
+ const story = await useAsyncStoryblok(
348
+ "blog",
349
+ {
350
+ version: config.public.storyblokVersion,
351
+ resolve_relations: "overview.featured_story"
352
+ },
353
+ { resolveRelations: "overview.featured_story" }
354
+ );
355
+
356
+ //or
335
357
 
336
- #### useAsyncStoryblok(slug, apiOptions, bridgeOptions)
358
+ const { data: articles } = await storyblokApi.get("cdn/stories", {
359
+ version: config.public.storyblokVersion,
360
+ starts_with: "blog",
361
+ is_startpage: false
362
+ });
363
+ ```
364
+
365
+ ## API
366
+
367
+ ### useAsyncStoryblok(slug, apiOptions, bridgeOptions)
337
368
 
338
369
  (Recommended Option) Uses [`useState`](https://v3.nuxtjs.org/api/composables/use-state) under the hood to help with SSR compatibility.
339
370
 
340
371
  Check the available [apiOptions](https://www.storyblok.com/docs/api/content-delivery/v2#core-resources/stories/retrieve-one-story?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt) (passed to `storyblok-js-client`) and [bridgeOptions](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt) (passed to the Storyblok Bridge).
341
372
 
342
- #### useStoryblok(slug, apiOptions, bridgeOptions)
373
+ ### useStoryblok(slug, apiOptions, bridgeOptions)
343
374
 
344
375
  It could be helpful to use `useStoryblok` instead of `useAsyncStoryblok` when we need to make full client-side requests, for example, getting personalized data for a logged user.
345
376
 
346
377
  Check the available [apiOptions](https://www.storyblok.com/docs/api/content-delivery/v2#core-resources/stories/retrieve-one-story?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt) (passed to `storyblok-js-client`) and [bridgeOptions](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt) (passed to the Storyblok Bridge).
347
378
 
348
- #### useStoryblokApi()
379
+ ### useStoryblokApi()
349
380
 
350
381
  Returns the instance of the `storyblok-js-client`.
351
382
 
352
- #### useStoryblokBridge(storyId, callback, bridgeOptions)
383
+ ### useStoryblokBridge(storyId, callback, bridgeOptions)
353
384
 
354
385
  Use this one-line function to cover the most common use case: updating the story when any kind of change happens on Storyblok Visual Editor.
355
386
 
@@ -357,22 +388,20 @@ Use this one-line function to cover the most common use case: updating the story
357
388
 
358
389
  ![A visual representation of the Storyblok JavaScript SDK Ecosystem](https://a.storyblok.com/f/88751/2400x1350/be4a4a4180/sdk-ecosystem.png/m/1200x0)
359
390
 
360
- ## 🔗 Related Links
361
-
362
- - **[Live Demo on Stackblitz](https://stackblitz.com/edit/nuxt-3-sdk-demo?file=pages%2Findex.vue&terminal=dev)**
363
- - **[Nuxt.js Hub](https://www.storyblok.com/tc/nuxtjs?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt)**: Learn how to develop your own Nuxt.js applications that use Storyblok APIs to retrieve and manage content;
364
- - **[Storyblok & Nuxt.js on GitHub](https://github.com/search?q=org%3Astoryblok+topic%3Anuxt)**: Check all of our Nuxt.js open source repos;
365
- - **[Storyblok CLI](https://github.com/storyblok/storyblok)**: A simple CLI for scaffolding Storyblok projects and fieldtypes.
391
+ ## Further Resources
366
392
 
367
- ## ℹ️ More Resources
393
+ - [Quick Start](https://www.storyblok.com/technologies?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt)
394
+ - [API Documentation](https://www.storyblok.com/docs/api?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt)
395
+ - [Developer Tutorials](https://www.storyblok.com/tutorials?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt)
396
+ - [Developer Guides](https://www.storyblok.com/docs/guide/introduction?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt)
397
+ - [FAQs](https://www.storyblok.com/faqs?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt)
368
398
 
369
- ### Support
399
+ ## Support
370
400
 
371
401
  - Bugs or Feature Requests? [Submit an issue](/../../issues/new);
372
-
373
402
  - Do you have questions about Storyblok or you need help? [Join our Discord Community](https://discord.gg/jKrbAMz).
374
403
 
375
- ### Contributing
404
+ ## Contributing
376
405
 
377
406
  Please see our [contributing guidelines](https://github.com/storyblok/.github/blob/master/contributing.md) and our [code of conduct](https://www.storyblok.com/trust-center#code-of-conduct?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt).
378
407
  This project use [semantic-release](https://semantic-release.gitbook.io/semantic-release/) for generate new versions by using commit messages and we use the Angular Convention to naming the commits. Check [this question](https://semantic-release.gitbook.io/semantic-release/support/faq#how-can-i-change-the-type-of-commits-that-trigger-a-release) about it in semantic-release FAQ.
package/dist/module.d.mts CHANGED
@@ -9,6 +9,6 @@ interface ModuleOptions {
9
9
  apiOptions: any;
10
10
  componentsDir: string;
11
11
  }
12
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
12
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
13
13
 
14
14
  export { type ModuleOptions, _default as default };
package/dist/module.d.ts CHANGED
@@ -9,6 +9,6 @@ interface ModuleOptions {
9
9
  apiOptions: any;
10
10
  componentsDir: string;
11
11
  }
12
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
12
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
13
13
 
14
14
  export { type ModuleOptions, _default as default };
package/dist/module.json CHANGED
@@ -1,5 +1,9 @@
1
1
  {
2
2
  "name": "@storyblok/nuxt",
3
3
  "configKey": "storyblok",
4
- "version": "6.0.10"
4
+ "version": "6.0.11",
5
+ "builder": {
6
+ "@nuxt/module-builder": "0.8.3",
7
+ "unbuild": "2.0.0"
8
+ }
5
9
  }
@@ -1,2 +1,4 @@
1
- import type { ISbStoriesParams, StoryblokBridgeConfigV2 } from '@storyblok/vue';
2
- export declare const useAsyncStoryblok: (url: string, apiOptions?: ISbStoriesParams, bridgeOptions?: StoryblokBridgeConfigV2) => Promise<any>;
1
+ import type { ISbStoriesParams, StoryblokBridgeConfigV2, ISbStoryData } from '@storyblok/vue';
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
+ }>>>;
@@ -1,2 +1,2 @@
1
- declare const _default: any;
1
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
2
2
  export default _default;
package/dist/types.d.mts CHANGED
@@ -1,16 +1 @@
1
-
2
- import type { ModuleOptions } from './module.js'
3
-
4
-
5
- declare module '@nuxt/schema' {
6
- interface NuxtConfig { ['storyblok']?: Partial<ModuleOptions> }
7
- interface NuxtOptions { ['storyblok']?: ModuleOptions }
8
- }
9
-
10
- declare module 'nuxt/schema' {
11
- interface NuxtConfig { ['storyblok']?: Partial<ModuleOptions> }
12
- interface NuxtOptions { ['storyblok']?: ModuleOptions }
13
- }
14
-
15
-
16
- export type { ModuleOptions, default } from './module.js'
1
+ export { type ModuleOptions, default } from './module.js'
package/dist/types.d.ts CHANGED
@@ -1,16 +1 @@
1
-
2
- import type { ModuleOptions } from './module'
3
-
4
-
5
- declare module '@nuxt/schema' {
6
- interface NuxtConfig { ['storyblok']?: Partial<ModuleOptions> }
7
- interface NuxtOptions { ['storyblok']?: ModuleOptions }
8
- }
9
-
10
- declare module 'nuxt/schema' {
11
- interface NuxtConfig { ['storyblok']?: Partial<ModuleOptions> }
12
- interface NuxtOptions { ['storyblok']?: ModuleOptions }
13
- }
14
-
15
-
16
- export type { ModuleOptions, default } from './module'
1
+ export { type ModuleOptions, default } from './module'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/nuxt",
3
- "version": "6.0.10",
3
+ "version": "6.0.11",
4
4
  "description": "Storyblok Nuxt module",
5
5
  "type": "module",
6
6
  "main": "./dist/module.cjs",
@@ -16,13 +16,13 @@
16
16
  "dist"
17
17
  ],
18
18
  "scripts": {
19
- "prepack": "nuxt-module-build",
20
- "build": "nuxt-module-build",
19
+ "prepack": "nuxt-module-build build",
20
+ "build": "nuxt-module-build build",
21
21
  "dev": "nuxi dev playground",
22
22
  "dev:build": "nuxi build playground",
23
23
  "dev:preview": "nuxi preview playground",
24
24
  "prepare:playground": "nuxi prepare playground",
25
- "dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
25
+ "dev:prepare": "nuxt-module-build build --stub && nuxi prepare playground",
26
26
  "prepare": "husky install",
27
27
  "cy:open": "cypress open",
28
28
  "cy:run": "cypress run",
@@ -36,21 +36,21 @@
36
36
  "@commitlint/cli": "^19.0.3",
37
37
  "@commitlint/config-conventional": "^19.0.3",
38
38
  "@cypress/vite-dev-server": "^5.0.6",
39
- "@nuxt/eslint-config": "^0.3.6",
40
- "@nuxt/kit": "^3.8.0",
41
- "@nuxt/module-builder": "^0.5.2",
42
- "@nuxt/schema": "^3.8.0",
43
- "@nuxt/test-utils": "^3.8.0",
39
+ "@nuxt/eslint-config": "^0.5.2",
40
+ "@nuxt/kit": "^3.13.0",
41
+ "@nuxt/module-builder": "^0.8.3",
42
+ "@nuxt/schema": "^3.13.0",
43
+ "@nuxt/test-utils": "^3.14.1",
44
44
  "@nuxtjs/eslint-config-typescript": "latest",
45
45
  "@types/node": "^20.8.10",
46
46
  "cypress": "^13.4.0",
47
47
  "eslint": "^8.52.0",
48
48
  "eslint-config-prettier": "^9.0.0",
49
- "eslint-plugin-cypress": "^2.15.1",
49
+ "eslint-plugin-cypress": "^3.0.0",
50
50
  "eslint-plugin-vue": "^9.18.1",
51
51
  "husky": "^9.0.6",
52
52
  "lint-staged": "^15.0.2",
53
- "nuxt": "^3.8.0",
53
+ "nuxt": "^3.13.0",
54
54
  "prettier": "^3.0.3",
55
55
  "start-server-and-test": "^2.0.1"
56
56
  },
File without changes