File tree Expand file tree Collapse file tree 5 files changed +13
-15
lines changed Expand file tree Collapse file tree 5 files changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -11,5 +11,5 @@ fileignoreconfig:
11
11
- filename: src/sdk/utils.ts
12
12
checksum: 00fb0674684ede99467f5d77012d92136481d54c75894768646e58703ae0fa5a
13
13
- filename: src/sdk/entry.ts
14
- checksum: 42de7b871970e732d243f1183b5eacf1ebe36f3dc0560afa6cc257107f696c25
14
+ checksum: 33b8aa8ad61a79911b22c61b418094034b308ca96bdebdc2619398337433fa1d
15
15
version: "1.0"
Original file line number Diff line number Diff line change 1
1
MIT License
2
2
3
- Copyright (c) 2024 Contentstack
3
+ Copyright (c) 2025 Contentstack
4
4
5
5
Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
of this software and associated documentation files (the "Software"), to deal
Original file line number Diff line number Diff line change @@ -2,8 +2,9 @@ import { getEntry, getEntryByUrl } from "../sdk/entry";
2
2
import { addEditableTags } from "@contentstack/utils" ;
3
3
import { FooterRes , HeaderRes } from "../typescript/response" ;
4
4
import { BlogPostRes , Page } from "../typescript/pages" ;
5
+ import { ENV } from "../sdk/utils" ;
5
6
6
- const liveEdit = import . meta . env . VITE_CONTENTSTACK_LIVE_EDIT_TAGS === "true" ;
7
+ const liveEdit = ENV . LIVE_EDIT_TAGS === "true" ;
7
8
8
9
export const getHeaderRes = async ( ) : Promise < HeaderRes > => {
9
10
const response = ( await getEntry ( {
Original file line number Diff line number Diff line change 5
5
customHostUrl ,
6
6
initializeContentStackSdk ,
7
7
isValidCustomHostUrl ,
8
+ ENV ,
8
9
} from "./utils" ;
9
10
10
11
type GetEntry = {
@@ -20,14 +21,8 @@ type GetEntryByUrl = {
20
21
jsonRtePath : string [ ] | undefined ;
21
22
} ;
22
23
23
- // Get environment variables using Vite's import.meta.env
24
- const VITE_CONTENTSTACK_API_HOST = import . meta. env . VITE_CONTENTSTACK_API_HOST ;
25
- const VITE_CONTENTSTACK_API_KEY = import . meta. env . VITE_CONTENTSTACK_API_KEY ;
26
- const VITE_CONTENTSTACK_APP_HOST = import . meta. env . VITE_CONTENTSTACK_APP_HOST ;
27
-
28
- const customHostBaseUrl = VITE_CONTENTSTACK_API_HOST ? customHostUrl (
29
- VITE_CONTENTSTACK_API_HOST as string
30
- ) : "" ;
24
+ // Get custom host base URL from ENV.API_HOST
25
+ const customHostBaseUrl = ENV . API_HOST ? customHostUrl ( ENV . API_HOST ) : "" ;
31
26
32
27
// SDK initialization
33
28
const Stack = initializeContentStackSdk ( ) ;
@@ -41,13 +36,13 @@ if (customHostBaseUrl && isValidCustomHostUrl(customHostBaseUrl)) {
41
36
ContentstackLivePreview . init ( {
42
37
//@ts -ignore
43
38
stackSdk : Stack ,
44
- enable : true ,
39
+ enable : ENV . LIVE_PREVIEW === " true" ,
45
40
mode : "builder" ,
46
41
stackDetails : {
47
- apiKey : VITE_CONTENTSTACK_API_KEY ,
42
+ apiKey : ENV . API_KEY ,
48
43
} ,
49
44
clientUrlParams :{
50
- host : VITE_CONTENTSTACK_APP_HOST
45
+ host : ENV . APP_HOST
51
46
}
52
47
} ) ?. catch ( ( error ) => console . error ( error ) ) ;
53
48
Original file line number Diff line number Diff line change 1
1
import { Config , Region , LivePreview , Stack } from "contentstack" ;
2
2
3
3
// Extract environment variables for easier access and maintenance
4
- const ENV = {
4
+ export const ENV = {
5
5
API_KEY : import . meta. env . VITE_CONTENTSTACK_API_KEY as string ,
6
6
DELIVERY_TOKEN : import . meta. env . VITE_CONTENTSTACK_DELIVERY_TOKEN as string ,
7
7
ENVIRONMENT : import . meta. env . VITE_CONTENTSTACK_ENVIRONMENT as string ,
@@ -11,6 +11,8 @@ const ENV = {
11
11
PREVIEW_TOKEN : import . meta. env . VITE_CONTENTSTACK_PREVIEW_TOKEN as string ,
12
12
PREVIEW_HOST : import . meta. env . VITE_CONTENTSTACK_PREVIEW_HOST as string ,
13
13
APP_HOST : import . meta. env . VITE_CONTENTSTACK_APP_HOST as string ,
14
+ API_HOST : import . meta. env . VITE_CONTENTSTACK_API_HOST as string ,
15
+ LIVE_EDIT_TAGS : import . meta. env . VITE_CONTENTSTACK_LIVE_EDIT_TAGS as string ,
14
16
} ;
15
17
16
18
// basic env validation
You can’t perform that action at this time.
0 commit comments