Skip to content

Commit f153e63

Browse files
refactor: License updated
1 parent f784084 commit f153e63

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

.talismanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ fileignoreconfig:
1111
- filename: src/sdk/utils.ts
1212
checksum: 00fb0674684ede99467f5d77012d92136481d54c75894768646e58703ae0fa5a
1313
- filename: src/sdk/entry.ts
14-
checksum: 42de7b871970e732d243f1183b5eacf1ebe36f3dc0560afa6cc257107f696c25
14+
checksum: 33b8aa8ad61a79911b22c61b418094034b308ca96bdebdc2619398337433fa1d
1515
version: "1.0"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Contentstack
3+
Copyright (c) 2025 Contentstack
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

src/helper/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { getEntry, getEntryByUrl } from "../sdk/entry";
22
import { addEditableTags } from "@contentstack/utils";
33
import { FooterRes, HeaderRes } from "../typescript/response";
44
import { BlogPostRes, Page } from "../typescript/pages";
5+
import { ENV } from "../sdk/utils";
56

6-
const liveEdit = import.meta.env.VITE_CONTENTSTACK_LIVE_EDIT_TAGS === "true";
7+
const liveEdit = ENV.LIVE_EDIT_TAGS === "true";
78

89
export const getHeaderRes = async (): Promise<HeaderRes> => {
910
const response = (await getEntry({

src/sdk/entry.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
customHostUrl,
66
initializeContentStackSdk,
77
isValidCustomHostUrl,
8+
ENV,
89
} from "./utils";
910

1011
type GetEntry = {
@@ -20,14 +21,8 @@ type GetEntryByUrl = {
2021
jsonRtePath: string[] | undefined;
2122
};
2223

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) : "";
3126

3227
// SDK initialization
3328
const Stack = initializeContentStackSdk();
@@ -41,13 +36,13 @@ if (customHostBaseUrl && isValidCustomHostUrl(customHostBaseUrl)) {
4136
ContentstackLivePreview.init({
4237
//@ts-ignore
4338
stackSdk: Stack,
44-
enable: true,
39+
enable: ENV.LIVE_PREVIEW === "true",
4540
mode: "builder",
4641
stackDetails: {
47-
apiKey: VITE_CONTENTSTACK_API_KEY,
42+
apiKey: ENV.API_KEY,
4843
},
4944
clientUrlParams:{
50-
host: VITE_CONTENTSTACK_APP_HOST
45+
host: ENV.APP_HOST
5146
}
5247
})?.catch((error) => console.error(error));
5348

src/sdk/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Config, Region, LivePreview, Stack } from "contentstack";
22

33
// Extract environment variables for easier access and maintenance
4-
const ENV = {
4+
export const ENV = {
55
API_KEY: import.meta.env.VITE_CONTENTSTACK_API_KEY as string,
66
DELIVERY_TOKEN: import.meta.env.VITE_CONTENTSTACK_DELIVERY_TOKEN as string,
77
ENVIRONMENT: import.meta.env.VITE_CONTENTSTACK_ENVIRONMENT as string,
@@ -11,6 +11,8 @@ const ENV = {
1111
PREVIEW_TOKEN: import.meta.env.VITE_CONTENTSTACK_PREVIEW_TOKEN as string,
1212
PREVIEW_HOST: import.meta.env.VITE_CONTENTSTACK_PREVIEW_HOST as string,
1313
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,
1416
};
1517

1618
// basic env validation

0 commit comments

Comments
 (0)