@storyblok/nuxt 4.4.2 → 4.5.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
@@ -74,7 +74,8 @@ export default defineNuxtConfig({
74
74
 
75
75
  #### Options
76
76
 
77
- When you initialize the module, you can pass all [_@storyblok/vue_ options](https://github.com/storyblok/storyblok-vue#storyblok-api) plus a `useApiClient` options:
77
+ 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' } }`.
78
+
78
79
 
79
80
  ```js
80
81
  // Defaults
@@ -162,10 +163,39 @@ You can easily render rich text by using the `renderRichText` function that come
162
163
  </template>
163
164
 
164
165
  <script setup>
166
+ const props = defineProps({ blok: Object })
165
167
  const articleContent = computed(() => renderRichText(blok.articleContent));
166
168
  </script>
167
169
  ```
168
170
 
171
+ You can also set a **custom Schema and component resolver** by passing the options as the second parameter of the `renderRichText` function:
172
+
173
+ ```html
174
+ <script setup>
175
+ import cloneDeep from 'clone-deep'
176
+
177
+ const mySchema = cloneDeep(RichTextSchema) // you can make a copy of the default RichTextSchema
178
+ // ... and edit the nodes and marks, or add your own.
179
+ // Check the base RichTextSchema source here https://github.com/storyblok/storyblok-js-client/blob/v4/source/schema.js
180
+
181
+ const props = defineProps({ blok: Object })
182
+
183
+ const articleContent = computed(() =>
184
+ renderRichText(props.blok.articleContent, {
185
+ schema: mySchema,
186
+ resolver: (component, blok) => {
187
+ switch (component) {
188
+ case 'my-custom-component':
189
+ return `<div class="my-component-class">${blok.text}</div>`
190
+ default:
191
+ return 'Resolver not defined'
192
+ }
193
+ },
194
+ })
195
+ )
196
+ </script>
197
+ ```
198
+
169
199
  ### API
170
200
 
171
201
  #### useAsyncStoryblok(slug, apiOptions, bridgeOptions)
package/dist/module.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { resolve } from 'path';
2
2
  import { fileURLToPath } from 'url';
3
- import { defineNuxtModule, addComponentsDir, addPlugin, addAutoImport, addAutoImportDir } from '@nuxt/kit';
3
+ import { defineNuxtModule, addComponentsDir, addPlugin, addImports, addImportsDir } from '@nuxt/kit';
4
4
 
5
5
  // -- Unbuild CommonJS Shims --
6
6
  import __cjs_url__ from 'url';
@@ -39,8 +39,8 @@ var module = defineNuxtModule({
39
39
  "renderRichText",
40
40
  "RichTextSchema"
41
41
  ];
42
- names.forEach((name) => addAutoImport({ name, as: name, from: "@storyblok/vue" }));
43
- addAutoImportDir(resolve(runtimeDir, `./composables`));
42
+ names.forEach((name) => addImports({ name, as: name, from: "@storyblok/vue" }));
43
+ addImportsDir(resolve(runtimeDir, `./composables`));
44
44
  }
45
45
  });
46
46
 
package/dist/module.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { resolve } from 'path';
2
2
  import { fileURLToPath } from 'url';
3
- import { defineNuxtModule, addComponentsDir, addPlugin, addAutoImport, addAutoImportDir } from '@nuxt/kit';
3
+ import { defineNuxtModule, addComponentsDir, addPlugin, addImports, addImportsDir } from '@nuxt/kit';
4
4
 
5
5
  // -- Unbuild CommonJS Shims --
6
6
  import __cjs_url__ from 'url';
@@ -39,8 +39,8 @@ const module = defineNuxtModule({
39
39
  "renderRichText",
40
40
  "RichTextSchema"
41
41
  ];
42
- names.forEach((name) => addAutoImport({ name, as: name, from: "@storyblok/vue" }));
43
- addAutoImportDir(resolve(runtimeDir, `./composables`));
42
+ names.forEach((name) => addImports({ name, as: name, from: "@storyblok/vue" }));
43
+ addImportsDir(resolve(runtimeDir, `./composables`));
44
44
  }
45
45
  });
46
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/nuxt",
3
- "version": "4.4.2",
3
+ "version": "4.5.0",
4
4
  "description": "Storyblok Nuxt.js module",
5
5
  "main": "./src/module.js",
6
6
  "module": "./src/module.js",
package/src/module.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  defineNuxtModule,
6
6
  addPlugin,
7
7
  addComponentsDir,
8
- addAutoImport,
9
- addAutoImportDir
8
+ addImports,
9
+ addImportsDir
10
10
  } from "@nuxt/kit";
11
11
 
12
12
  export default defineNuxtModule({
@@ -47,8 +47,8 @@ export default defineNuxtModule({
47
47
  "RichTextSchema"
48
48
  ];
49
49
  names.forEach((name) =>
50
- addAutoImport({ name, as: name, from: "@storyblok/vue" })
50
+ addImports({ name, as: name, from: "@storyblok/vue" })
51
51
  );
52
- addAutoImportDir(resolve(runtimeDir, `./composables`));
52
+ addImportsDir(resolve(runtimeDir, `./composables`));
53
53
  }
54
54
  });