1+ /* eslint-disable @typescript-eslint/ban-ts-comment */
12/* eslint-disable no-undef */
23import * as contentstack from "contentstack" ;
34import * as Utils from "@contentstack/utils" ;
45
56import ContentstackLivePreview from "@contentstack/live-preview-utils" ;
67
8+ type GetEntry = {
9+ contentTypeUid : string ;
10+ referenceFieldPath : string [ ] | undefined ;
11+ jsonRtePath : string [ ] | undefined ;
12+ } ;
13+
14+ type GetEntryByUrl = {
15+ entryUrl : string | undefined ;
16+ contentTypeUid : string ;
17+ referenceFieldPath : string [ ] | undefined ;
18+ jsonRtePath : string [ ] | undefined ;
19+ } ;
20+
721const Stack = contentstack . Stack ( {
8- api_key : process . env . REACT_APP_CONTENTSTACK_API_KEY ,
9- delivery_token : process . env . REACT_APP_CONTENTSTACK_DELIVERY_TOKEN ,
10- environment : process . env . REACT_APP_CONTENTSTACK_ENVIRONMENT ,
11- region : process . env . REACT_APP_CONTENTSTACK_REGION
12- ? process . env . REACT_APP_CONTENTSTACK_REGION
22+ api_key : `${ process . env . REACT_APP_CONTENTSTACK_API_KEY } ` ,
23+ delivery_token : `${ process . env . REACT_APP_CONTENTSTACK_DELIVERY_TOKEN } ` ,
24+ environment : `${ process . env . REACT_APP_CONTENTSTACK_ENVIRONMENT } ` ,
25+ //@ts -ignore
26+ region : `${ process . env . REACT_APP_CONTENTSTACK_REGION } `
27+ ? `${ process . env . REACT_APP_CONTENTSTACK_REGION } `
1328 : "us" ,
1429 live_preview : {
15- management_token : process . env . REACT_APP_CONTENTSTACK_MANAGEMENT_TOKEN
16- ? process . env . REACT_APP_CONTENTSTACK_MANAGEMENT_TOKEN
30+ management_token : ` ${ process . env . REACT_APP_CONTENTSTACK_MANAGEMENT_TOKEN } `
31+ ? ` ${ process . env . REACT_APP_CONTENTSTACK_MANAGEMENT_TOKEN } `
1732 : "" ,
1833 enable : true ,
19- host : process . env . REACT_APP_CONTENTSTACK_API_HOST
20- ? process . env . REACT_APP_CONTENTSTACK_API_HOST
34+ host : ` ${ process . env . REACT_APP_CONTENTSTACK_API_HOST } `
35+ ? ` ${ process . env . REACT_APP_CONTENTSTACK_API_HOST } `
2136 : "" ,
2237 } ,
2338} ) ;
@@ -27,21 +42,22 @@ const Stack = contentstack.Stack({
2742 */
2843ContentstackLivePreview . init ( {
2944 enable : true ,
45+ //@ts -ignore
3046 stackSdk : Stack ,
3147 clientUrlParams : {
32- host : process . env . REACT_APP_CONTENTSTACK_APP_HOST
33- ? process . env . REACT_APP_CONTENTSTACK_APP_HOST
48+ host : ` ${ process . env . REACT_APP_CONTENTSTACK_APP_HOST } `
49+ ? ` ${ process . env . REACT_APP_CONTENTSTACK_APP_HOST } `
3450 : "" ,
3551 } ,
3652 ssr : false ,
3753} ) ;
3854
39- if ( process . env . REACT_APP_CONTENTSTACK_API_HOST ) {
40- Stack . setHost ( process . env . REACT_APP_CONTENTSTACK_API_HOST ) ;
55+ if ( ` ${ process . env . REACT_APP_CONTENTSTACK_API_HOST } ` ) {
56+ Stack . setHost ( ` ${ process . env . REACT_APP_CONTENTSTACK_API_HOST } ` ) ;
4157}
4258
4359const renderOption = {
44- [ "span" ] : ( node , next ) => {
60+ [ "span" ] : ( node : any , next : any ) => {
4561 return next ( node . children ) ;
4662 } ,
4763} ;
@@ -57,7 +73,7 @@ export default {
5773 * @param {* Json RTE path } jsonRtePath
5874 *
5975 */
60- getEntry ( { contentTypeUid, referenceFieldPath, jsonRtePath } ) {
76+ getEntry ( { contentTypeUid, referenceFieldPath, jsonRtePath } : GetEntry ) {
6177 return new Promise ( ( resolve , reject ) => {
6278 const query = Stack . ContentType ( contentTypeUid ) . Query ( ) ;
6379 if ( referenceFieldPath ) query . includeReference ( referenceFieldPath ) ;
@@ -91,7 +107,12 @@ export default {
91107 * @param {* Json RTE path } jsonRtePath
92108 * @returns
93109 */
94- getEntryByUrl ( { contentTypeUid, entryUrl, referenceFieldPath, jsonRtePath } ) {
110+ getEntryByUrl ( {
111+ contentTypeUid,
112+ entryUrl,
113+ referenceFieldPath,
114+ jsonRtePath,
115+ } : GetEntryByUrl ) {
95116 return new Promise ( ( resolve , reject ) => {
96117 const blogQuery = Stack . ContentType ( contentTypeUid ) . Query ( ) ;
97118 if ( referenceFieldPath ) blogQuery . includeReference ( referenceFieldPath ) ;
0 commit comments