@storyblok/astro 7.4.0-alpha.0 → 8.1.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 +2 -2
- package/dist/index.d.ts +2 -4
- package/dist/lib/client.d.ts +0 -1
- package/dist/lib/client.ts +0 -2
- package/dist/lib/helpers.d.ts +0 -46
- package/dist/lib/richTextToHTML.d.ts +5 -5
- package/dist/live-preview/middleware.ts +7 -6
- package/dist/public.d.ts +1 -42
- package/dist/storyblok-astro.es.js +35403 -1092
- package/dist/storyblok-astro.umd.js +85 -16
- package/dist/types.d.ts +1 -1
- package/package.json +7 -10
- package/dist/components/StoryblokServerData.astro +0 -29
- package/dist/lib/richTextToHTML.ts +0 -103
- package/dist/lib/sanitizeJSON.d.ts +0 -30
- package/dist/utils/isEditorRequest.d.ts +0 -41
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ If you'd like to contribute, please refer to the [contributing guidelines](CONTR
|
|
|
50
50
|
|
|
51
51
|
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
|
52
52
|
|
|
53
|
-
- [Discuss Storyblok on
|
|
53
|
+
- [Discuss Storyblok on GitHub Discussions](https://github.com/storyblok/monoblok/discussions)
|
|
54
54
|
|
|
55
55
|
For community support, chatting with other users, please visit:
|
|
56
56
|
|
|
@@ -65,7 +65,7 @@ For bugs or feature requests, please [submit an issue](https://github.com/storyb
|
|
|
65
65
|
|
|
66
66
|
### I can't share my company project code
|
|
67
67
|
|
|
68
|
-
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
|
|
68
|
+
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. Please 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.
|
|
69
69
|
|
|
70
70
|
### Feedback
|
|
71
71
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/// <reference path="./public.d.ts" />
|
|
2
2
|
import { default as storyblokIntegration } from './lib/storyblok-integration';
|
|
3
|
-
export { getLiveStory,
|
|
4
|
-
export { sanitizeJSON } from './lib/sanitizeJSON';
|
|
3
|
+
export { getLiveStory, useStoryblokApi } from './lib/helpers';
|
|
5
4
|
export type { IntegrationOptions } from './lib/storyblok-integration';
|
|
6
5
|
export { handleStoryblokMessage } from './live-preview/handleStoryblokMessage';
|
|
7
6
|
export * from './types';
|
|
8
|
-
export { isEditorRequest } from './utils/isEditorRequest';
|
|
9
7
|
export { toCamelCase } from './utils/toCamelCase';
|
|
10
|
-
export { loadStoryblokBridge, renderRichText, richTextResolver, storyblokEditable, } from '@storyblok/js';
|
|
8
|
+
export { loadStoryblokBridge, renderRichText, richTextResolver, segmentStoryblokRichText, storyblokEditable, } from '@storyblok/js';
|
|
11
9
|
export { storyblokIntegration as storyblok };
|
|
12
10
|
export { apiPlugin, storyblokInit } from '@storyblok/js';
|
package/dist/lib/client.d.ts
CHANGED
package/dist/lib/client.ts
CHANGED
package/dist/lib/helpers.d.ts
CHANGED
|
@@ -23,9 +23,6 @@ export declare function useStoryblokApi(): StoryblokClient;
|
|
|
23
23
|
* This function is primarily useful when working with the Storyblok Visual Editor
|
|
24
24
|
* and live preview updates in an Astro project.
|
|
25
25
|
*
|
|
26
|
-
* @deprecated Use `getPayload()` instead for better type safety and to access both story and serverData.
|
|
27
|
-
* @see {@link getPayload}
|
|
28
|
-
*
|
|
29
26
|
* @param {Readonly<AstroGlobal>} Astro - The Astro global object.
|
|
30
27
|
* @returns {Promise<ISbStoryData | null>} The Storyblok story data if available,
|
|
31
28
|
* otherwise `null`.
|
|
@@ -39,47 +36,4 @@ export declare function useStoryblokApi(): StoryblokClient;
|
|
|
39
36
|
* ```
|
|
40
37
|
*/
|
|
41
38
|
export declare function getLiveStory(Astro: Readonly<AstroGlobal>): Promise<ISbStoryData | null>;
|
|
42
|
-
/**
|
|
43
|
-
* Retrieves the live Storyblok story and server data from Astro's `locals` during preview mode.
|
|
44
|
-
*
|
|
45
|
-
* This function is primarily useful when working with the Storyblok Visual Editor
|
|
46
|
-
* and live preview updates in an Astro project.
|
|
47
|
-
*
|
|
48
|
-
* @template ServerData - The type of server data, constrained to StoryblokServerData
|
|
49
|
-
* @template Story - The type of story data, constrained to ISbStoryData
|
|
50
|
-
* @param {object} params - The function parameters
|
|
51
|
-
* @param {object} params.locals - The Astro locals object
|
|
52
|
-
* @returns {Promise<{ story?: Story; serverData?: ServerData }>} An object containing the story and serverData if available
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* // Basic usage:
|
|
57
|
-
* const payload = await getPayload({ locals: Astro.locals });
|
|
58
|
-
* const story = payload.story ?? null;
|
|
59
|
-
*
|
|
60
|
-
* // With typed server data:
|
|
61
|
-
* interface ServerData {
|
|
62
|
-
* users?: User[];
|
|
63
|
-
* }
|
|
64
|
-
*
|
|
65
|
-
* interface MyStory extends ISbStoryData {
|
|
66
|
-
* content: { myField: string };
|
|
67
|
-
* }
|
|
68
|
-
*
|
|
69
|
-
* const payload = await getPayload<ServerData, MyStory>({ locals: Astro.locals });
|
|
70
|
-
* const story = payload.story ?? null;
|
|
71
|
-
* const users = payload.serverData?.users ?? [];
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export declare function getPayload<ServerData extends object = object, Story extends ISbStoryData = ISbStoryData>({ locals, }: {
|
|
75
|
-
locals: {
|
|
76
|
-
_storyblok_preview_data?: {
|
|
77
|
-
serverData?: ServerData;
|
|
78
|
-
story?: Story;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
}): Promise<{
|
|
82
|
-
story?: Story;
|
|
83
|
-
serverData?: ServerData;
|
|
84
|
-
}>;
|
|
85
39
|
export declare function initStoryblokBridge(config: boolean | StoryblokBridgeConfigV2): string;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { StoryblokRichTextNode,
|
|
1
|
+
import { StoryblokRichTextNode, StoryblokRichTextOptions } from '@storyblok/js';
|
|
2
2
|
/**
|
|
3
3
|
* @experimental Converts a Storyblok RichText field into an HTML string.
|
|
4
4
|
*
|
|
5
5
|
* This API is still under development and may change in future releases.
|
|
6
|
-
* It also relies on Astro
|
|
6
|
+
* It also relies on Astro's experimental
|
|
7
7
|
* [experimental_AstroContainer](https://docs.astro.build/en/reference/container-reference/) feature.
|
|
8
8
|
*
|
|
9
9
|
* @async
|
|
10
10
|
* @param {StoryblokRichTextNode} richTextField - The root RichText node to convert.
|
|
11
|
-
* @param {
|
|
12
|
-
* for customizing how specific nodes or marks are
|
|
11
|
+
* @param {StoryblokRichTextOptions['tiptapExtensions']} [tiptapExtensions] - Optional custom
|
|
12
|
+
* tiptap extensions for customizing how specific nodes or marks are rendered.
|
|
13
13
|
* @returns {Promise<string>} A promise that resolves to the HTML string representation
|
|
14
14
|
* of the provided RichText content.
|
|
15
15
|
*
|
|
@@ -24,4 +24,4 @@ import { StoryblokRichTextNode, StoryblokRichTextResolvers } from '@storyblok/js
|
|
|
24
24
|
* <div set:html={renderedRichText} />
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
export declare const richTextToHTML: (richTextField: StoryblokRichTextNode,
|
|
27
|
+
export declare const richTextToHTML: (richTextField: StoryblokRichTextNode, tiptapExtensions?: StoryblokRichTextOptions["tiptapExtensions"]) => Promise<string>;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { defineMiddleware } from 'astro/middleware';
|
|
2
|
-
import { isEditorRequest } from '@storyblok/astro';
|
|
3
2
|
|
|
4
3
|
export const onRequest = defineMiddleware(async ({ locals, request }, next) => {
|
|
5
4
|
if (request.method === 'POST') {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
// First do a basic check if its coming from within storyblok
|
|
7
|
+
const isStoryblokRequest
|
|
8
|
+
= url.searchParams.has('_storyblok')
|
|
9
|
+
&& url.searchParams.has('_storyblok_c');
|
|
9
10
|
|
|
10
|
-
if (
|
|
11
|
+
if (isStoryblokRequest) {
|
|
11
12
|
try {
|
|
12
13
|
// Create a copy of the request
|
|
13
14
|
const requestBody = await request.clone().json();
|
|
14
|
-
if (requestBody
|
|
15
|
+
if (requestBody && requestBody.is_storyblok_preview) {
|
|
15
16
|
locals._storyblok_preview_data = requestBody;
|
|
16
17
|
}
|
|
17
18
|
}
|
package/dist/public.d.ts
CHANGED
|
@@ -16,49 +16,8 @@ declare module '@storyblok/astro/StoryblokComponent.astro' {
|
|
|
16
16
|
/** Renders a dynamic Storyblok component */
|
|
17
17
|
export default StoryblokComponent;
|
|
18
18
|
}
|
|
19
|
-
declare module '@storyblok/astro/StoryblokServerData.astro' {
|
|
20
|
-
function StoryblokServerData(
|
|
21
|
-
_props: Record<string, unknown>
|
|
22
|
-
): any;
|
|
23
|
-
|
|
24
|
-
/** Renders a dynamic Storyblok component */
|
|
25
|
-
export default StoryblokServerData;
|
|
26
|
-
}
|
|
27
19
|
declare module '@storyblok/astro/client' {
|
|
28
|
-
import type {
|
|
29
|
-
StoryblokClient,
|
|
30
|
-
StoryblokRichTextNode,
|
|
31
|
-
StoryblokRichTextResolvers,
|
|
32
|
-
} from '@storyblok/astro';
|
|
33
|
-
/**
|
|
34
|
-
* @experimental Converts a Storyblok RichText field into an HTML string.
|
|
35
|
-
*
|
|
36
|
-
* This API is still under development and may change in future releases.
|
|
37
|
-
* It also relies on Astro’s experimental
|
|
38
|
-
* [experimental_AstroContainer](https://docs.astro.build/en/reference/container-reference/) feature.
|
|
39
|
-
*
|
|
40
|
-
* @async
|
|
41
|
-
* @param {StoryblokRichTextNode} richTextField - The root RichText node to convert.
|
|
42
|
-
* @param {StoryblokRichTextResolvers} [customResolvers] - Optional custom resolvers
|
|
43
|
-
* for customizing how specific nodes or marks are transformed into HTML.
|
|
44
|
-
* @returns {Promise<string>} A promise that resolves to the HTML string representation
|
|
45
|
-
* of the provided RichText content.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```astro
|
|
49
|
-
* ---
|
|
50
|
-
* import { richTextToHTML } from '@storyblok/astro/client';
|
|
51
|
-
* const { blok } = Astro.props;
|
|
52
|
-
* const renderedRichText = await richTextToHTML(blok.text);
|
|
53
|
-
* ---
|
|
54
|
-
*
|
|
55
|
-
* <div set:html={renderedRichText} />
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export function richTextToHTML(
|
|
59
|
-
richTextField: StoryblokRichTextNode,
|
|
60
|
-
customResolvers?: StoryblokRichTextResolvers
|
|
61
|
-
): Promise<string>;
|
|
20
|
+
import type { StoryblokClient } from '@storyblok/astro';
|
|
62
21
|
|
|
63
22
|
/**
|
|
64
23
|
* Provides direct access to the initialized Storyblok API client instance.
|