@storyblok/vue 8.2.3 → 9.0.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 +24 -487
- package/dist/index.d.ts +1 -1
- package/dist/storyblok-vue.js +2 -25
- package/dist/storyblok-vue.mjs +601 -927
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
13
|
<a href="https://npmjs.com/package/@storyblok/vue">
|
|
14
|
-
<img src="https://img.shields.io/npm/v/@storyblok/vue/latest.svg?style=flat-square" alt="Storyblok Vue" />
|
|
14
|
+
<img src="https://img.shields.io/npm/v/@storyblok/vue/latest.svg?style=flat-square" alt="Storyblok Vue SDK" />
|
|
15
15
|
</a>
|
|
16
16
|
<a href="https://npmjs.com/package/@storyblok/vue" rel="nofollow">
|
|
17
17
|
<img src="https://img.shields.io/npm/dt/@storyblok/vue.svg?style=flat-square" alt="npm">
|
|
@@ -30,509 +30,46 @@
|
|
|
30
30
|
</a>
|
|
31
31
|
</p>
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
> This plugin is for Vue 3. [Check out the docs for Vue 2 version](https://github.com/storyblok/storyblok-vue-2).
|
|
33
|
+
## Features
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
- Fetch content from the Content Delivery API
|
|
36
|
+
- Connect frontend components with the Visual Editor via StoryblokBridge
|
|
37
|
+
- Render rich text content by providing a built-in component and composable
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
## Documentation
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
For complete documentation, please visit [package reference](https://www.storyblok.com/docs/packages/storyblok-vue)
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
## Installation
|
|
45
|
-
|
|
46
|
-
Install `@storyblok/vue`
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
npm install @storyblok/vue
|
|
50
|
-
# yarn add @storyblok/vue
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
> **Warning**
|
|
54
|
-
> 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).
|
|
55
|
-
|
|
56
|
-
Register the plugin on your application (usually in `main.js`), add the `apiPlugin` and add the [access token](https://www.storyblok.com/docs/api/content-delivery/v2/getting-started/authentication?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue) of your Storyblok space:
|
|
57
|
-
|
|
58
|
-
```js
|
|
59
|
-
import { createApp } from "vue";
|
|
60
|
-
import { StoryblokVue, apiPlugin } from "@storyblok/vue";
|
|
61
|
-
import App from "./App.vue";
|
|
62
|
-
|
|
63
|
-
const app = createApp(App);
|
|
64
|
-
|
|
65
|
-
app.use(StoryblokVue, {
|
|
66
|
-
accessToken: "YOUR_ACCESS_TOKEN",
|
|
67
|
-
use: [apiPlugin],
|
|
68
|
-
});
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
That's it! All the features are enabled for you: the _Api Client_ for interacting with [Storyblok CDN API](https://www.storyblok.com/docs/api/content-delivery/v2/getting-started/introduction?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue), and _Storyblok Bridge_ for [real-time visual editing experience](https://www.storyblok.com/docs/guide/essentials/visual-editor?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue).
|
|
72
|
-
|
|
73
|
-
> **Note**
|
|
74
|
-
> You can enable/disable some of these features if you don't need them, so you save some KB. Please read the "Features and API" section.
|
|
75
|
-
|
|
76
|
-
#### From a CDN
|
|
77
|
-
|
|
78
|
-
Install the file from the CDN and access the methods via `window.storyblokVue`:
|
|
79
|
-
|
|
80
|
-
```html
|
|
81
|
-
<script src="https://unpkg.com/@storyblok/vue"></script>
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Getting started
|
|
85
|
-
|
|
86
|
-
`@storyblok/vue` does three actions when you initialize it:
|
|
87
|
-
|
|
88
|
-
- Provides a `storyblokApi` object in your app, which is an instance of [storyblok-js-client](https://github.com/storyblok/storyblok-js-client)
|
|
89
|
-
- Loads [Storyblok Bridge](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue) for real-time visual updates
|
|
90
|
-
- Provides a `v-editable` directive to link editable components to the Storyblok Visual Editor
|
|
91
|
-
|
|
92
|
-
### Short Form
|
|
93
|
-
|
|
94
|
-
Load globally the Vue components you want to link to Storyblok in your _main.js_ file:
|
|
95
|
-
|
|
96
|
-
```js
|
|
97
|
-
import Page from "./components/Page.vue";
|
|
98
|
-
import Teaser from "./components/Teaser.vue";
|
|
99
|
-
|
|
100
|
-
app.use(StoryblokVue, {
|
|
101
|
-
accessToken: "<your-token>",
|
|
102
|
-
use: [apiPlugin],
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
app.component("Page", Page);
|
|
106
|
-
app.component("Teaser", Teaser);
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
The simplest way is by using the `useStoryblok` one-liner composable. Where you need to pass as first parameter the `slug`, while the second and third parameters, `apiOptions` and `bridgeOptions` respectively, are optional:
|
|
110
|
-
|
|
111
|
-
> **Note**
|
|
112
|
-
> The `resolveRelations` and `resolveLinks` from `bridgeOptions` can be excluded if you're already defining them as `resolve_relations` and `resolve_links` in `apiOptions`, we will add them by default. But you will always be able to overwrite them.
|
|
113
|
-
|
|
114
|
-
```html
|
|
115
|
-
<script setup>
|
|
116
|
-
import { useStoryblok } from "@storyblok/vue";
|
|
117
|
-
const { story, fetchState } = useStoryblok(
|
|
118
|
-
"path-to-story",
|
|
119
|
-
{ version: "draft", resolve_relations: "Article.author" }, // API Options
|
|
120
|
-
{ resolveRelations: ["Article.author"], resolveLinks: "url" } // Bridge Options
|
|
121
|
-
);
|
|
122
|
-
</script>
|
|
123
|
-
|
|
124
|
-
<template>
|
|
125
|
-
<StoryblokComponent v-if="story" :blok="story.content" />
|
|
126
|
-
</template>
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
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-vue) 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-vue) passed to the Storyblok Bridge.
|
|
130
|
-
|
|
131
|
-
### Long Form
|
|
132
|
-
|
|
133
|
-
#### 1. Fetching Content
|
|
134
|
-
|
|
135
|
-
Inject `storyblokApi` when using Composition API:
|
|
136
|
-
|
|
137
|
-
```html
|
|
138
|
-
<template>
|
|
139
|
-
<div>
|
|
140
|
-
<p v-for="story in stories" :key="story.id">{{ story.name }}</p>
|
|
141
|
-
</div>
|
|
142
|
-
</template>
|
|
143
|
-
|
|
144
|
-
<script setup>
|
|
145
|
-
import { useStoryblokApi } from "@storyblok/vue";
|
|
146
|
-
|
|
147
|
-
const storyblokApi = useStoryblokApi();
|
|
148
|
-
const { data } = await storyblokApi.get(
|
|
149
|
-
"cdn/stories/home",
|
|
150
|
-
{ version: "draft", resolve_relations: "Article.author" } // API Options
|
|
151
|
-
);
|
|
152
|
-
</script>
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
> **Note**
|
|
156
|
-
> You can skip using `apiPlugin` if you prefer your own method or function to fetch your data.
|
|
157
|
-
|
|
158
|
-
#### 2. Listen to Storyblok Visual Editor events
|
|
159
|
-
|
|
160
|
-
Use `useStoryBridge` to get the new story every time is triggered a `change` event from the Visual Editor. You need to pass the story id as first param, and a callback function as second param to update the new story:
|
|
161
|
-
|
|
162
|
-
```html
|
|
163
|
-
<script setup>
|
|
164
|
-
import { onMounted } from "vue";
|
|
165
|
-
import { useStoryblokBridge, useStoryblokApi } from "@storyblok/vue";
|
|
166
|
-
|
|
167
|
-
const storyblokApi = useStoryblokApi();
|
|
168
|
-
const { data } = await storyblokApi.get(
|
|
169
|
-
"cdn/stories/home",
|
|
170
|
-
{ version: "draft", resolve_relations: "Article.author" } // API Options
|
|
171
|
-
);
|
|
172
|
-
const state = reactive({ story: data.story });
|
|
173
|
-
|
|
174
|
-
onMounted(() => {
|
|
175
|
-
useStoryblokBridge(state.story.id, story => (state.story = story));
|
|
176
|
-
});
|
|
177
|
-
</script>
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
You can pass [Bridge options](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue) as a third parameter as well:
|
|
181
|
-
|
|
182
|
-
```js
|
|
183
|
-
useStoryblokBridge(
|
|
184
|
-
state.story.id,
|
|
185
|
-
(story) => (state.story = story),
|
|
186
|
-
{
|
|
187
|
-
resolveRelations: ["Article.author"],
|
|
188
|
-
resolveLinks: "url",
|
|
189
|
-
} // Bridge Options
|
|
190
|
-
);
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
#### 3. Link your components to Storyblok Visual Editor
|
|
194
|
-
|
|
195
|
-
For every component you've defined in your Storyblok space, add the `v-editable` directive with the blok content:
|
|
196
|
-
|
|
197
|
-
```html
|
|
198
|
-
<template>
|
|
199
|
-
<div v-editable="blok"><!-- ... --></div>
|
|
200
|
-
</template>
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
Where `blok` is the actual blok data coming from [Storblok's Content Delivery API](https://www.storyblok.com/docs/api/content-delivery?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue).
|
|
204
|
-
|
|
205
|
-
Check out the [playground](/../../tree/next/playground) for a full example.
|
|
206
|
-
|
|
207
|
-
## Features and API
|
|
208
|
-
|
|
209
|
-
You can **choose the features to use** when you initialize the plugin. In that way, you can improve Web Performance by optimizing your page load and save some bytes.
|
|
210
|
-
|
|
211
|
-
### useStoryblok(pathToStory, apiOptions = {}, bridgeOptions = {})
|
|
212
|
-
|
|
213
|
-
This example of `useStoryblok`:
|
|
214
|
-
|
|
215
|
-
```html
|
|
216
|
-
<script setup>
|
|
217
|
-
import { useStoryblok } from "@storyblok/vue";
|
|
218
|
-
const story = await useStoryblok(
|
|
219
|
-
"blog",
|
|
220
|
-
{ version: "draft", resolve_relations: "Article.author" }, // API Options
|
|
221
|
-
{ resolveRelations: ["Article.author"], resolveLinks: "url" } // Bridge Options
|
|
222
|
-
);
|
|
223
|
-
</script>
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
Is equivalent to the following, using `useStoryblokBridge` and `useStoryblokApi`:
|
|
227
|
-
|
|
228
|
-
```html
|
|
229
|
-
<script setup>
|
|
230
|
-
import { onMounted } from "vue";
|
|
231
|
-
import { useStoryblokBridge, useStoryblokApi } from "@storyblok/vue";
|
|
232
|
-
|
|
233
|
-
const storyblokApi = useStoryblokApi();
|
|
234
|
-
const { data } = await storyblokApi.get(
|
|
235
|
-
"cdn/stories/blog",
|
|
236
|
-
{ version: "draft", resolve_relations: "Article.author" }, // API Options
|
|
237
|
-
);
|
|
238
|
-
const state = reactive({ story: data.story });
|
|
239
|
-
|
|
240
|
-
onMounted(() => {
|
|
241
|
-
useStoryblokBridge(
|
|
242
|
-
state.story.id,
|
|
243
|
-
story => (state.story = story),
|
|
244
|
-
{ resolveRelations: ["Article.author"], resolveLinks: "url" } // Bridge Options
|
|
245
|
-
);
|
|
246
|
-
});
|
|
247
|
-
</script>
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
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-vue) (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-vue) (passed to the Storyblok Bridge).
|
|
251
|
-
|
|
252
|
-
### Storyblok API
|
|
253
|
-
|
|
254
|
-
You can use an `apiOptions` object. This is passed down to the [storyblok-js-client config object](https://github.com/storyblok/storyblok-js-client#class-storyblok).
|
|
255
|
-
|
|
256
|
-
```js
|
|
257
|
-
app.use(StoryblokVue, {
|
|
258
|
-
accessToken: "<your-token>",
|
|
259
|
-
apiOptions: {
|
|
260
|
-
// storyblok-js-client config object
|
|
261
|
-
cache: { type: "memory" },
|
|
262
|
-
},
|
|
263
|
-
use: [apiPlugin],
|
|
264
|
-
});
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
If you prefer to use your own fetch method, just remove the `apiPlugin` and `storyblok-js-client` won't be added to your application.
|
|
268
|
-
|
|
269
|
-
```js
|
|
270
|
-
app.use(StoryblokVue);
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
## Region parameter
|
|
274
|
-
|
|
275
|
-
Possible values:
|
|
276
|
-
|
|
277
|
-
- `eu` (default): For spaces created in the EU
|
|
278
|
-
- `us`: For spaces created in the US
|
|
279
|
-
- `ap`: For spaces created in Australia
|
|
280
|
-
- `ca`: For spaces created in Canada
|
|
281
|
-
- `cn`: For spaces created in China
|
|
282
|
-
|
|
283
|
-
Full example for a space created in the US:
|
|
284
|
-
|
|
285
|
-
```js
|
|
286
|
-
app.use(StoryblokVue, {
|
|
287
|
-
accessToken: "<your-token>",
|
|
288
|
-
use: [apiPlugin],
|
|
289
|
-
apiOptions: {
|
|
290
|
-
region: "us",
|
|
291
|
-
},
|
|
292
|
-
});
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
> **Important**
|
|
296
|
-
> For spaces created in the United States or China, the `region` parameter **must** be specified.
|
|
297
|
-
|
|
298
|
-
## Storyblok Bridge
|
|
299
|
-
|
|
300
|
-
You can conditionally load it by using the `bridge` option. Very useful if you want to disable it in production:
|
|
301
|
-
|
|
302
|
-
```js
|
|
303
|
-
app.use(StoryblokVue, {
|
|
304
|
-
bridge: process.env.NODE_ENV !== "production",
|
|
305
|
-
});
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
In case you need it, you have still access to the raw `window.StoryblokBridge`:
|
|
309
|
-
|
|
310
|
-
```js
|
|
311
|
-
const sbBridge = new window.StoryblokBridge(options);
|
|
312
|
-
|
|
313
|
-
sbBridge.on(["input", "published", "change"], (event) => {
|
|
314
|
-
// ...
|
|
315
|
-
});
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
## Using Fallback components
|
|
319
|
-
|
|
320
|
-
By default, `@storyblok/vue` show a `console.error` if a component is not implemented. Setting `enableFallbackComponent` to `true` bypasses that behavior, rendering a fallback component in the frontend instead.
|
|
321
|
-
|
|
322
|
-
```js
|
|
323
|
-
app.use(StoryblokVue, {
|
|
324
|
-
// ...
|
|
325
|
-
enableFallbackComponent: true,
|
|
326
|
-
});
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
You can also create and use a custom fallback component by setting `customFallbackComponent: "MyCustomFallback"`.
|
|
330
|
-
|
|
331
|
-
```js
|
|
332
|
-
import MyCustomFallback from "./components/MyCustomFallback.vue";
|
|
333
|
-
|
|
334
|
-
app.use(StoryblokVue, {
|
|
335
|
-
// ...
|
|
336
|
-
enableFallbackComponent: true,
|
|
337
|
-
customFallbackComponent: "MyCustomFallback",
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
app.component("MyCustomFallback", MyCustomFallback);
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
## Rendering Rich Text
|
|
344
|
-
|
|
345
|
-
You can render rich text fields by using the `StoryblokRichText` component:
|
|
346
|
-
|
|
347
|
-
```html
|
|
348
|
-
<script setup>
|
|
349
|
-
import { StoryblokRichText } from "@storyblok/vue";
|
|
350
|
-
</script>
|
|
351
|
-
|
|
352
|
-
<template>
|
|
353
|
-
<StoryblokRichText :doc="blok.articleContent" />
|
|
354
|
-
</template>
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
Or you can have more control by using the `useStoryblokRichText` composable:
|
|
358
|
-
|
|
359
|
-
```html
|
|
360
|
-
<script setup>
|
|
361
|
-
import { useStoryblokRichText } from "@storyblok/vue";
|
|
362
|
-
const { render } = useStoryblokRichText({
|
|
363
|
-
// options like resolvers
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
const root = () => render(blok.articleContent);
|
|
367
|
-
</script>
|
|
368
|
-
|
|
369
|
-
<template>
|
|
370
|
-
<root />
|
|
371
|
-
</template>
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
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.
|
|
375
|
-
|
|
376
|
-
### Overriding the default resolvers
|
|
377
|
-
|
|
378
|
-
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: :
|
|
379
|
-
|
|
380
|
-
```html
|
|
381
|
-
<script setup>
|
|
382
|
-
import { type VNode, h } from "vue";
|
|
383
|
-
import { StoryblokRichText, BlockTypes, MarkTypes, type StoryblokRichTextNode } from "@storyblok/vue";
|
|
384
|
-
import { RouterLink } from "vue-router";
|
|
385
|
-
import CodeBlok from "./components/CodeBlok.vue";
|
|
386
|
-
|
|
387
|
-
const resolvers = {
|
|
388
|
-
// RouterLink example:
|
|
389
|
-
[MarkTypes.LINK]: (node: StoryblokRichTextNode<VNode>) => {
|
|
390
|
-
return node.attrs?.linktype === 'STORY'
|
|
391
|
-
? h(RouterLink, {
|
|
392
|
-
to: node.attrs?.href,
|
|
393
|
-
target: node.attrs?.target,
|
|
394
|
-
}, node.text)
|
|
395
|
-
: h('a', {
|
|
396
|
-
href: node.attrs?.href,
|
|
397
|
-
target: node.attrs?.target,
|
|
398
|
-
}, node.text)
|
|
399
|
-
},
|
|
400
|
-
// Custom code block component example:
|
|
401
|
-
[BlockTypes.CODE_BLOCK]: (node: Node) => {
|
|
402
|
-
return h(CodeBlock, {
|
|
403
|
-
class: node?.attrs?.class,
|
|
404
|
-
}, node.children)
|
|
405
|
-
},
|
|
406
|
-
}
|
|
407
|
-
</script>
|
|
408
|
-
|
|
409
|
-
<template>
|
|
410
|
-
<StoryblokRichText :doc="blok.articleContent" :resolvers="resolvers" />
|
|
411
|
-
</template>
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
If you want to use the `useStoryblokRichText` composable, you can pass the `resolvers` via the options object:
|
|
415
|
-
|
|
416
|
-
```html
|
|
417
|
-
<script setup>
|
|
418
|
-
import { type VNode, h } from "vue";
|
|
419
|
-
import { useStoryblokRichText, BlockTypes, MarkTypes, type StoryblokRichTextNode } from "@storyblok/vue";
|
|
420
|
-
import { RouterLink } from "vue-router";
|
|
421
|
-
|
|
422
|
-
const resolvers = {
|
|
423
|
-
// RouterLink example:
|
|
424
|
-
[MarkTypes.LINK]: (node: StoryblokRichTextNode<VNode>) => {
|
|
425
|
-
return node.attrs?.linktype === 'STORY'
|
|
426
|
-
? h(RouterLink, {
|
|
427
|
-
to: node.attrs?.href,
|
|
428
|
-
target: node.attrs?.target,
|
|
429
|
-
}, node.text)
|
|
430
|
-
: h('a', {
|
|
431
|
-
href: node.attrs?.href,
|
|
432
|
-
target: node.attrs?.target,
|
|
433
|
-
}, node.text)
|
|
434
|
-
},
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
const { render } = useStoryblokRichText({
|
|
438
|
-
resolvers,
|
|
439
|
-
})
|
|
440
|
-
const root = () => render(blok.articleContent);
|
|
441
|
-
</script>
|
|
442
|
-
|
|
443
|
-
<template>
|
|
444
|
-
<root />
|
|
445
|
-
</template>
|
|
446
|
-
```
|
|
447
|
-
|
|
448
|
-
### Legacy Rich Text Resolver
|
|
449
|
-
|
|
450
|
-
> [!WARNING]
|
|
451
|
-
> The legacy `richTextResolver` is soon to be deprecated. We recommend migrating to the new approach described above instead.
|
|
452
|
-
|
|
453
|
-
You can easily render rich text by using the `renderRichText` function that comes with `@storyblok/vue` and a Vue computed property:
|
|
454
|
-
|
|
455
|
-
```html
|
|
456
|
-
<template>
|
|
457
|
-
<div v-html="articleContent"></div>
|
|
458
|
-
</template>
|
|
459
|
-
|
|
460
|
-
<script setup>
|
|
461
|
-
import { computed } from "vue";
|
|
462
|
-
import { renderRichText } from "@storyblok/vue";
|
|
463
|
-
|
|
464
|
-
const articleContent = computed(() => renderRichText(blok.articleContent));
|
|
465
|
-
</script>
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
You can set a **custom Schema and component resolver globally** at init time by using the `richText` init option:
|
|
43
|
+
## Contributing
|
|
469
44
|
|
|
470
|
-
|
|
471
|
-
import { RichTextSchema, StoryblokVue } from "@storyblok/vue";
|
|
472
|
-
import cloneDeep from "clone-deep";
|
|
45
|
+
If you'd like to contribute, please refer to the [contributing guidelines](CONTRIBUTING.md).
|
|
473
46
|
|
|
474
|
-
|
|
475
|
-
// ... and edit the nodes and marks, or add your own.
|
|
476
|
-
// Check the base RichTextSchema source here https://github.com/storyblok/storyblok-js-client/blob/master/source/schema.js
|
|
47
|
+
## Community
|
|
477
48
|
|
|
478
|
-
|
|
479
|
-
accessToken: "YOUR_ACCESS_TOKEN",
|
|
480
|
-
use: [apiPlugin],
|
|
481
|
-
richText: {
|
|
482
|
-
schema: mySchema,
|
|
483
|
-
resolver: (component, blok) => {
|
|
484
|
-
switch (component) {
|
|
485
|
-
case "my-custom-component":
|
|
486
|
-
return `<div class="my-component-class">${blok.text}</div>`;
|
|
487
|
-
default:
|
|
488
|
-
return "Resolver not defined";
|
|
489
|
-
}
|
|
490
|
-
},
|
|
491
|
-
},
|
|
492
|
-
});
|
|
493
|
-
```
|
|
49
|
+
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
|
494
50
|
|
|
495
|
-
|
|
51
|
+
- [Discuss Storyblok on Github Discussions](https://github.com/storyblok/storyblok/discussions)
|
|
496
52
|
|
|
497
|
-
|
|
498
|
-
import { renderRichText } from "@storyblok/vue";
|
|
53
|
+
For community support, chatting with other users, please visit:
|
|
499
54
|
|
|
500
|
-
|
|
501
|
-
schema: mySchema,
|
|
502
|
-
resolver: (component, blok) => {
|
|
503
|
-
switch (component) {
|
|
504
|
-
case "my-custom-component":
|
|
505
|
-
return `<div class="my-component-class">${blok.text}</div>`;
|
|
506
|
-
break;
|
|
507
|
-
default:
|
|
508
|
-
return `Component ${component} not found`;
|
|
509
|
-
}
|
|
510
|
-
},
|
|
511
|
-
});
|
|
512
|
-
```
|
|
55
|
+
- [Discuss Storyblok on Discord](https://discord.gg/jKrbAMz)
|
|
513
56
|
|
|
514
|
-
##
|
|
57
|
+
## Support
|
|
515
58
|
|
|
516
|
-
|
|
59
|
+
For bugs or feature requests, please [submit an issue](https://github.com/storyblok/storyblok-vue/issues/new/choose).
|
|
517
60
|
|
|
518
|
-
|
|
61
|
+
> [!IMPORTANT]
|
|
62
|
+
> Please search existing issues before submitting a new one. Issues without a minimal reproducible example will be closed. [Why reproductions are Required](https://antfu.me/posts/why-reproductions-are-required).
|
|
519
63
|
|
|
520
|
-
|
|
64
|
+
### I can't share my company project code
|
|
521
65
|
|
|
522
|
-
|
|
66
|
+
We understand that you might not be able to share your company's project code. Please provide a minimal reproducible example that demonstrates the issue by using tools like [Stackblitz](https://stackblitz.com) or a link to a Github Repo lease make sure you include a README file with the instructions to build and run the project, important not to include any access token, password or personal information of any kind.
|
|
523
67
|
|
|
524
|
-
|
|
525
|
-
- [API Documentation](https://www.storyblok.com/docs/api?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue)
|
|
526
|
-
- [Developer Tutorials](https://www.storyblok.com/tutorials?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue)
|
|
527
|
-
- [Developer Guides](https://www.storyblok.com/docs/guide/introduction?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue)
|
|
528
|
-
- [FAQs](https://www.storyblok.com/faqs?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue)
|
|
68
|
+
### Feedback
|
|
529
69
|
|
|
530
|
-
|
|
70
|
+
If you have a question, please ask in the [Discuss Storyblok on Discord](https://discord.gg/jKrbAMz) channel.
|
|
531
71
|
|
|
532
|
-
- Bugs or Feature Requests? [Submit an issue](/../../issues/new).
|
|
533
|
-
- Do you have questions about Storyblok or you need help? [Join our Discord Community](https://discord.gg/jKrbAMz).
|
|
534
72
|
|
|
535
|
-
##
|
|
73
|
+
## License
|
|
536
74
|
|
|
537
|
-
|
|
538
|
-
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.
|
|
75
|
+
[License](/LICENSE)
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { default as StoryblokComponent } from './components/StoryblokComponent.v
|
|
|
4
4
|
export { default as StoryblokRichText } from './components/StoryblokRichText.vue';
|
|
5
5
|
export * from './composables/useStoryblokRichText';
|
|
6
6
|
export * from './types';
|
|
7
|
-
export { apiPlugin, BlockTypes, MarkTypes, renderRichText,
|
|
7
|
+
export { apiPlugin, BlockTypes, MarkTypes, renderRichText, richTextResolver, type StoryblokRichTextDocumentNode, type StoryblokRichTextImageOptimizationOptions, type StoryblokRichTextNode, type StoryblokRichTextNodeResolver, type StoryblokRichTextNodeTypes, type StoryblokRichTextOptions, type StoryblokRichTextResolvers, TextTypes, useStoryblokBridge, } from '@storyblok/js';
|
|
8
8
|
export declare const useStoryblokApi: () => StoryblokClient;
|
|
9
9
|
export declare const useStoryblok: (url: string, apiOptions?: ISbStoriesParams, bridgeOptions?: StoryblokBridgeConfigV2) => Promise<Ref<ISbStoryData<import('@storyblok/js').StoryblokComponentType<string> & {
|
|
10
10
|
[index: string]: any;
|