diff --git a/.talismanrc b/.talismanrc index 8bf0a97..b119597 100644 --- a/.talismanrc +++ b/.talismanrc @@ -11,5 +11,5 @@ fileignoreconfig: - filename: src/sdk/utils.ts checksum: 00fb0674684ede99467f5d77012d92136481d54c75894768646e58703ae0fa5a - filename: src/sdk/entry.ts - checksum: 33b8aa8ad61a79911b22c61b418094034b308ca96bdebdc2619398337433fa1d + checksum: 4f8b6df5fa08a66e57286a0dd69d1b49064f7f4540a627e8fa63730b6ee9cbf3 version: "1.0" \ No newline at end of file diff --git a/src/sdk/entry.ts b/src/sdk/entry.ts index 5797895..fb7d58d 100644 --- a/src/sdk/entry.ts +++ b/src/sdk/entry.ts @@ -32,19 +32,21 @@ if (customHostBaseUrl && isValidCustomHostUrl(customHostBaseUrl)) { Stack.setHost(customHostBaseUrl); } -// Setting LP if enabled -ContentstackLivePreview.init({ - //@ts-ignore - stackSdk: Stack, - enable: ENV.LIVE_PREVIEW === "true", - mode: "builder", - stackDetails: { - apiKey: ENV.API_KEY, - }, - clientUrlParams:{ - host: ENV.APP_HOST - } -})?.catch((error) => console.error(error)); +if (ENV.LIVE_PREVIEW === "true") { + // Setting LP if enabled + ContentstackLivePreview.init({ + //@ts-ignore + stackSdk: Stack, + enable: ENV.LIVE_PREVIEW === "true", + mode: "builder", + stackDetails: { + apiKey: ENV.API_KEY, + }, + clientUrlParams: { + host: ENV.APP_HOST + } + })?.catch((error) => console.error(error)); +} export const { onEntryChange } = ContentstackLivePreview; diff --git a/src/sdk/utils.ts b/src/sdk/utils.ts index c4bfb63..e6671ac 100644 --- a/src/sdk/utils.ts +++ b/src/sdk/utils.ts @@ -27,7 +27,7 @@ export const isBasicConfigValid = () => { // Live preview config validation export const isLpConfigValid = () => { return ( - !!ENV.LIVE_PREVIEW && + ENV.LIVE_PREVIEW === "true" && !!ENV.PREVIEW_TOKEN && !!ENV.PREVIEW_HOST && !!ENV.APP_HOST @@ -75,7 +75,7 @@ export const initializeContentStackSdk = (): Stack => { }; // api host url -export const customHostUrl = (baseUrl=''): string => { +export const customHostUrl = (baseUrl = ''): string => { return baseUrl.replace("api", "cdn"); };