Releases: episerver/content-js-sdk
Releases · episerver/content-js-sdk
@episerver/[email protected]
This version includes new methods to support fetching variations form the CMS
Summary:
- BREAKING CHANGE. New method
GraphClient.getContentByPath
(replacesGraphClient.fetchContent
) - BREAKING CHANGE New method
GraphClient.getPreviewContent
(replacesGraphClient.fetchPreviewContent
)
Get content variations with GraphClient.getContentByPath
With one parameter
The new method getContentByPath
returns an array of items instead of a single item.
Before:
const client = new GraphClient();
const content = await client.fetchContent('/en/home');
return <OptimizelyComponent opti={content} />;
After:
const client = new GraphClient();
const items = await client.getContentByPath('/en/home');
return <OptimizelyComponent opti={items[0]} />;
With two parameters
The same method accepts a second parameter (options) where you can pass options to include or exclude variations.
If you want to get all the variations for the path:
const items = await client.getContentByPath('/en/home', {
variation: { include: 'ALL' },
});
If you want to get certain variations (for example, if you want to get the content with variation ID equal to variation2
):
const items = await client.getContentByPath('/en/home', {
variation: { include: 'SOME', value: ['variation2'] },
});
When using include: SOME
, the original variation is not included by default. To include the original, pass the flag includeOriginal: true
:
const items = await client.getContentByPath('/en/home', {
variation: {
include: 'SOME',
value: ['variation2'],
includeOriginal: true,
},
});
New GraphClient.getPreviewContent
method
This method has the same API as the old fetchPreviewContent
client.getPreviewContent((await searchParams) as PreviewParams);
You don't need to make any change to support previewing variations