@storyblok/nuxt 4.4.1 → 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 +31 -1
- package/dist/module.d.ts +5 -4
- package/dist/module.mjs +5 -4
- package/package.json +1 -1
- package/src/module.js +6 -5
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`
|
|
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,
|
|
3
|
+
import { defineNuxtModule, addComponentsDir, addPlugin, addImports, addImportsDir } from '@nuxt/kit';
|
|
4
4
|
|
|
5
5
|
// -- Unbuild CommonJS Shims --
|
|
6
6
|
import __cjs_url__ from 'url';
|
|
@@ -36,10 +36,11 @@ var module = defineNuxtModule({
|
|
|
36
36
|
"useStoryblok",
|
|
37
37
|
"useStoryblokApi",
|
|
38
38
|
"useStoryblokBridge",
|
|
39
|
-
"renderRichText"
|
|
39
|
+
"renderRichText",
|
|
40
|
+
"RichTextSchema"
|
|
40
41
|
];
|
|
41
|
-
names.forEach((name) =>
|
|
42
|
-
|
|
42
|
+
names.forEach((name) => addImports({ name, as: name, from: "@storyblok/vue" }));
|
|
43
|
+
addImportsDir(resolve(runtimeDir, `./composables`));
|
|
43
44
|
}
|
|
44
45
|
});
|
|
45
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,
|
|
3
|
+
import { defineNuxtModule, addComponentsDir, addPlugin, addImports, addImportsDir } from '@nuxt/kit';
|
|
4
4
|
|
|
5
5
|
// -- Unbuild CommonJS Shims --
|
|
6
6
|
import __cjs_url__ from 'url';
|
|
@@ -36,10 +36,11 @@ const module = defineNuxtModule({
|
|
|
36
36
|
"useStoryblok",
|
|
37
37
|
"useStoryblokApi",
|
|
38
38
|
"useStoryblokBridge",
|
|
39
|
-
"renderRichText"
|
|
39
|
+
"renderRichText",
|
|
40
|
+
"RichTextSchema"
|
|
40
41
|
];
|
|
41
|
-
names.forEach((name) =>
|
|
42
|
-
|
|
42
|
+
names.forEach((name) => addImports({ name, as: name, from: "@storyblok/vue" }));
|
|
43
|
+
addImportsDir(resolve(runtimeDir, `./composables`));
|
|
43
44
|
}
|
|
44
45
|
});
|
|
45
46
|
|
package/package.json
CHANGED
package/src/module.js
CHANGED
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
defineNuxtModule,
|
|
6
6
|
addPlugin,
|
|
7
7
|
addComponentsDir,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
addImports,
|
|
9
|
+
addImportsDir
|
|
10
10
|
} from "@nuxt/kit";
|
|
11
11
|
|
|
12
12
|
export default defineNuxtModule({
|
|
@@ -43,11 +43,12 @@ export default defineNuxtModule({
|
|
|
43
43
|
"useStoryblok",
|
|
44
44
|
"useStoryblokApi",
|
|
45
45
|
"useStoryblokBridge",
|
|
46
|
-
"renderRichText"
|
|
46
|
+
"renderRichText",
|
|
47
|
+
"RichTextSchema"
|
|
47
48
|
];
|
|
48
49
|
names.forEach((name) =>
|
|
49
|
-
|
|
50
|
+
addImports({ name, as: name, from: "@storyblok/vue" })
|
|
50
51
|
);
|
|
51
|
-
|
|
52
|
+
addImportsDir(resolve(runtimeDir, `./composables`));
|
|
52
53
|
}
|
|
53
54
|
});
|