@storyblok/astro 6.1.0-alpha.2 → 6.1.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 +27 -1
- package/dist/components/StoryblokComponent.astro +9 -6
- package/dist/index.d.ts +1 -3
- package/dist/storyblok-astro.es.js +494 -825
- package/dist/storyblok-astro.umd.js +8 -8
- package/dist/vite-plugins/vite-plugin-storyblok-options.d.ts +1 -2
- package/package.json +5 -3
- package/dist/content-loader/storyblokLoader.d.ts +0 -11
package/README.md
CHANGED
|
@@ -351,7 +351,33 @@ document.addEventListener('storyblok-live-preview-updated', () => {
|
|
|
351
351
|
});
|
|
352
352
|
</script>
|
|
353
353
|
```
|
|
354
|
-
|
|
354
|
+
|
|
355
|
+
## Rendering Rich Text
|
|
356
|
+
|
|
357
|
+
> [!NOTE]
|
|
358
|
+
> The `@storyblok/astro` now provides the exports for the new `richTextResolver` API from `@storyblok/js`. Until a dedicated `StoryblokRichText.astro` is developed, we recommend using the vanilla solution below.
|
|
359
|
+
|
|
360
|
+
```jsx
|
|
361
|
+
---
|
|
362
|
+
import { richTextResolver } from "@storyblok/astro";
|
|
363
|
+
|
|
364
|
+
const renderedRichText = richTextResolver({
|
|
365
|
+
// options like custom resolvers
|
|
366
|
+
}).render(doc);
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
<div set:html={renderedRichText}></div>
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
To learn more about the new `richTextResolver` API, please refer to the [storyblok-richtext docs](https://github.com/storyblok/richtext).
|
|
373
|
+
|
|
374
|
+
Similar to the legacy `renderRichText` function, this vanilla approach only supports parsing and returning native HTML tags, if you are not embedding `bloks` in your rich text. Then you can use the [`set:html` directive](https://docs.astro.build/en/reference/directives-reference/#sethtml):
|
|
375
|
+
|
|
376
|
+
## Legacy Rendering Rich Text
|
|
377
|
+
|
|
378
|
+
> [!WARNING]
|
|
379
|
+
> The legacy `richTextResolver` is soon to be deprecated. We recommend migrating to the new approach described above instead.
|
|
380
|
+
|
|
355
381
|
|
|
356
382
|
> [!NOTE]
|
|
357
383
|
> While @storyblok/astro provides basic richtext rendering capabilities, for advanced use cases, it is highly recommended to use [storyblok-rich-text-astro-renderer](https://github.com/NordSecurity/storyblok-rich-text-astro-renderer).
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
import components from
|
|
3
|
-
import options from
|
|
4
|
-
import { toCamelCase } from
|
|
5
|
-
import type { SbBlokData } from
|
|
6
|
-
import type { AstroComponentFactory } from
|
|
2
|
+
import components from "virtual:storyblok-components";
|
|
3
|
+
import options from "virtual:storyblok-options";
|
|
4
|
+
import { toCamelCase } from "@storyblok/astro";
|
|
5
|
+
import type { SbBlokData } from "@storyblok/js";
|
|
6
|
+
import type { AstroComponentFactory } from "astro/runtime/server/index.js";
|
|
7
7
|
|
|
8
8
|
export interface Props {
|
|
9
9
|
blok: SbBlokData;
|
|
10
10
|
[prop: string]: unknown;
|
|
11
11
|
}
|
|
12
|
+
|
|
12
13
|
const { blok, ...props } = Astro.props;
|
|
13
14
|
|
|
14
15
|
if (!blok) {
|
|
@@ -23,14 +24,16 @@ if (!blok) {
|
|
|
23
24
|
let key = toCamelCase(blok.component as string);
|
|
24
25
|
|
|
25
26
|
const componentFound: boolean = key in components;
|
|
27
|
+
|
|
26
28
|
let Component: AstroComponentFactory;
|
|
29
|
+
|
|
27
30
|
if (!componentFound) {
|
|
28
31
|
if (!options.enableFallbackComponent)
|
|
29
32
|
throw new Error(
|
|
30
33
|
`Component could not be found for blok "${blok.component}"! Is it defined in astro.config.mjs?`
|
|
31
34
|
);
|
|
32
35
|
else {
|
|
33
|
-
Component = components[
|
|
36
|
+
Component = components["FallbackComponent"];
|
|
34
37
|
}
|
|
35
38
|
} else {
|
|
36
39
|
Component = components[key];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { default as storyblokIntegration } from './lib/storyblok-integration';
|
|
2
|
-
export { storyblokLoader } from './content-loader/storyblokLoader';
|
|
3
2
|
export { getLiveStory, renderRichText, useStoryblokApi } from './lib/helpers';
|
|
4
|
-
export type { IntegrationOptions } from './lib/storyblok-integration';
|
|
5
3
|
export { handleStoryblokMessage } from './live-preview/handleStoryblokMessage';
|
|
6
4
|
export * from './types';
|
|
7
5
|
export { toCamelCase } from './utils/toCamelCase';
|
|
6
|
+
export { loadStoryblokBridge, RichTextResolver, richTextResolver, RichTextSchema, storyblokEditable, type StoryblokRichTextDocumentNode, type StoryblokRichTextImageOptimizationOptions, type StoryblokRichTextNode, type StoryblokRichTextNodeResolver, type StoryblokRichTextNodeTypes, type StoryblokRichTextOptions, type StoryblokRichTextResolvers, TextTypes, } from '@storyblok/js';
|
|
8
7
|
export { storyblokIntegration as storyblok };
|
|
9
|
-
export { loadStoryblokBridge, RichTextResolver, RichTextSchema, storyblokEditable, } from '@storyblok/js';
|