@storyblok/nuxt 6.1.1 → 6.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/README.md +94 -5
- package/dist/module.json +1 -1
- package/dist/module.mjs +7 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
</p>
|
|
29
29
|
|
|
30
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
|
|
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?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt#nuxt)**, and get started in just a few minutes!
|
|
32
32
|
|
|
33
33
|
## Ultimate Tutorial
|
|
34
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.
|
|
@@ -212,7 +212,7 @@ To link your Vue components to the equivalent one in your Storyblok space:
|
|
|
212
212
|
|
|
213
213
|
The simplest way is by using the `useAsyncStoryblok` one-liner composable (it's autoimported). Where you need to pass as first parameter the `slug`, while the second and third parameters, `apiOptions` and `bridgeOptions` respectively, are optional.
|
|
214
214
|
|
|
215
|
-
Check the available [apiOptions](https://www.storyblok.com/docs/api/content-delivery/v2
|
|
215
|
+
Check the available [apiOptions](https://www.storyblok.com/docs/api/content-delivery/v2/stories/retrieve-a-single-story?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt) in our API docs 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.
|
|
216
216
|
|
|
217
217
|
> **Note**
|
|
218
218
|
> 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)
|
|
@@ -271,6 +271,95 @@ Which is the short-hand equivalent to using `useStoryblokApi` inside `useState`
|
|
|
271
271
|
|
|
272
272
|
## Rendering Rich Text
|
|
273
273
|
|
|
274
|
+
You can render rich text fields by using the `StoryblokRichText` component:
|
|
275
|
+
|
|
276
|
+
```html
|
|
277
|
+
<template>
|
|
278
|
+
<StoryblokRichText :doc="blok.articleContent" />
|
|
279
|
+
</template>
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Or you can have more control by using the `useStoryblokRichText` composable:
|
|
283
|
+
|
|
284
|
+
```html
|
|
285
|
+
<script setup>
|
|
286
|
+
const { render } = useStoryblokRichText({
|
|
287
|
+
// options like resolvers
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
const root = () => render(blok.articleContent);
|
|
291
|
+
</script>
|
|
292
|
+
|
|
293
|
+
<template>
|
|
294
|
+
<root />
|
|
295
|
+
</template>
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
For more incredible options you can pass to the `useStoryblokRichText`, please consult the [Full options](https://github.com/storyblok/richtext?tab=readme-ov-file#options) documentation.
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
#### Overriding the default resolvers
|
|
302
|
+
|
|
303
|
+
You can override the default resolvers by passing a `resolver` prop to the `StoryblokRichText` component, for example, to use vue-router links or add a custom codeblok component: :
|
|
304
|
+
|
|
305
|
+
```html
|
|
306
|
+
<script setup>
|
|
307
|
+
import { NuxtLink } from '#components';
|
|
308
|
+
import type { StoryblokRichTextNode } from '@storyblok/vue';
|
|
309
|
+
import CodeBlok from "./components/CodeBlok.vue";
|
|
310
|
+
|
|
311
|
+
const resolvers = {
|
|
312
|
+
// NuxtLink example:
|
|
313
|
+
[MarkTypes.LINK]: (node: StoryblokRichTextNode<VNode>) =>
|
|
314
|
+
h(NuxtLink, {
|
|
315
|
+
to: node.attrs?.href,
|
|
316
|
+
target: node.attrs?.target,
|
|
317
|
+
}, node.text),
|
|
318
|
+
// Custom code block component example:
|
|
319
|
+
[BlockTypes.CODE_BLOCK]: (node: Node) => {
|
|
320
|
+
return h(CodeBlock, {
|
|
321
|
+
class: node?.attrs?.class,
|
|
322
|
+
}, node.children)
|
|
323
|
+
},
|
|
324
|
+
}
|
|
325
|
+
</script>
|
|
326
|
+
|
|
327
|
+
<template>
|
|
328
|
+
<StoryblokRichText :doc="blok.articleContent" :resolvers="resolvers" />
|
|
329
|
+
</template>
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
If you want to use the `useStoryblokRichText` composable, you can pass the `resolvers` via the options object:
|
|
333
|
+
|
|
334
|
+
```html
|
|
335
|
+
<script setup>
|
|
336
|
+
import CodeBlok from "./components/CodeBlok.vue";
|
|
337
|
+
|
|
338
|
+
const { render } = useStoryblokRichText({
|
|
339
|
+
resolvers: {
|
|
340
|
+
// NuxtLink example:
|
|
341
|
+
[MarkTypes.LINK]: (node: StoryblokRichTextNode<VNode>) =>
|
|
342
|
+
h(NuxtLink, {
|
|
343
|
+
to: node.attrs?.href,
|
|
344
|
+
target: node.attrs?.target,
|
|
345
|
+
}, node.text),
|
|
346
|
+
// Custom code block component example:
|
|
347
|
+
[BlockTypes.CODE_BLOCK]: (node: Node) =>
|
|
348
|
+
h(CodeBlock, {
|
|
349
|
+
class: node?.attrs?.class,
|
|
350
|
+
}, node.children)
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
const root = () => render(blok.articleContent);
|
|
355
|
+
</script>
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Legacy Rendering Rich Text
|
|
359
|
+
|
|
360
|
+
> [!WARNING]
|
|
361
|
+
> The legacy `richTextResolver` is soon to be deprecated. We recommend migrating to the new approach described above instead.
|
|
362
|
+
|
|
274
363
|
You can easily render rich text by using the `renderRichText` function that comes with `@storyblok/nuxt` and a Vue computed property:
|
|
275
364
|
|
|
276
365
|
```html
|
|
@@ -366,13 +455,13 @@ const { data: articles } = await storyblokApi.get('cdn/stories', {
|
|
|
366
455
|
|
|
367
456
|
(Recommended Option) Uses [`useState`](https://v3.nuxtjs.org/api/composables/use-state) under the hood to help with SSR compatibility.
|
|
368
457
|
|
|
369
|
-
Check the available [apiOptions](https://www.storyblok.com/docs/api/content-delivery/v2
|
|
458
|
+
Check the available [apiOptions](https://www.storyblok.com/docs/api/content-delivery/v2/stories/retrieve-a-single-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).
|
|
370
459
|
|
|
371
460
|
### useStoryblok(slug, apiOptions, bridgeOptions)
|
|
372
461
|
|
|
373
462
|
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.
|
|
374
463
|
|
|
375
|
-
Check the available [apiOptions](https://www.storyblok.com/docs/api/content-delivery/v2
|
|
464
|
+
Check the available [apiOptions](https://www.storyblok.com/docs/api/content-delivery/v2/stories/retrieve-a-single-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).
|
|
376
465
|
|
|
377
466
|
### useStoryblokApi()
|
|
378
467
|
|
|
@@ -401,5 +490,5 @@ Use this one-line function to cover the most common use case: updating the story
|
|
|
401
490
|
|
|
402
491
|
## Contributing
|
|
403
492
|
|
|
404
|
-
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
|
|
493
|
+
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?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-nuxt#code-of-conduct).
|
|
405
494
|
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.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -39,7 +39,13 @@ const module = defineNuxtModule({
|
|
|
39
39
|
"useStoryblokApi",
|
|
40
40
|
"useStoryblokBridge",
|
|
41
41
|
"renderRichText",
|
|
42
|
-
"RichTextSchema"
|
|
42
|
+
"RichTextSchema",
|
|
43
|
+
"StoryblokRichText",
|
|
44
|
+
"useStoryblokRichText",
|
|
45
|
+
"MarkTypes",
|
|
46
|
+
"BlockTypes",
|
|
47
|
+
"LinkTypes",
|
|
48
|
+
"AssetTypes"
|
|
43
49
|
];
|
|
44
50
|
for (const name of names) {
|
|
45
51
|
addImports({ name, as: name, from: "@storyblok/vue" });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.2.1",
|
|
5
5
|
"packageManager": "pnpm@9.9.0",
|
|
6
6
|
"description": "Storyblok Nuxt module",
|
|
7
7
|
"repository": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"lint:fix": "eslint . --fix"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@storyblok/vue": "^8.1.
|
|
44
|
+
"@storyblok/vue": "^8.1.9"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@commitlint/cli": "^19.5.0",
|