diff --git a/.env.sample b/.env.sample index 9c5b8ca..1ad4c3d 100644 --- a/.env.sample +++ b/.env.sample @@ -1,6 +1,7 @@ REACT_APP_CONTENTSTACK_API_KEY=YOUR_STACK_API_KEY REACT_APP_CONTENTSTACK_DELIVERY_TOKEN=YOUR_DELIVERY_TOKEN REACT_APP_CONTENTSTACK_ENVIRONMENT=YOUR_ENVIRONMENT +REACT_APP_CONTENTSTACK_PREVIEW_TOKEN=YOUR_PREVIEW_TOKEN # Supported Regions: # For AWS North America, set region as US diff --git a/README.md b/README.md index 3d7f3d0..31cc449 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ This is a React starter app that integrates with Contentstack's Content Delivery ``` REACT_APP_CONTENTSTACK_API_KEY=YOUR_STACK_API_KEY REACT_APP_CONTENTSTACK_DELIVERY_TOKEN=YOUR_DELIVERY_TOKEN + REACT_APP_CONTENTSTACK_PREVIEW_TOKEN=YOUR_PREVIEW_TOKEN REACT_APP_CONTENTSTACK_ENVIRONMENT=YOUR_ENVIRONMENT REACT_APP_CONTENTSTACK_REGION=YOUR_STACK_REGION ``` @@ -42,7 +43,7 @@ This is a React starter app that integrates with Contentstack's Content Delivery To configure the app with your Contentstack account: -- Replace `YOUR_STACK_API_KEY`, `YOUR_DELIVERY_TOKEN`, `YOUR_ENVIRONMENT` and `YOUR_STACK_REGION` in the `.env` file with your Contentstack API key, delivery token, environment name and region respectively. +- Replace `YOUR_STACK_API_KEY`, `YOUR_DELIVERY_TOKEN`, `YOUR_PREVIEW_TOKEN`, `YOUR_ENVIRONMENT` and `YOUR_STACK_REGION` in the `.env` file with your Contentstack API key, delivery token, environment name and region respectively. **Supported Regions:** @@ -52,6 +53,8 @@ To configure the app with your Contentstack account: - **Azure Europe:** `AZURE_EU` - **GCP North America:** `GCP_NA` +> 🚨 **Important Note:** **Live Preview** is not supported in the **GCP NA** region! 🚨 + ## Usage 1. Once the app is running, navigate to `http://localhost:3000` in your web browser. @@ -62,6 +65,7 @@ To configure the app with your Contentstack account: - Integration with Contentstack's Content Delivery API. - Dynamic rendering of content fetched from Contentstack. +- Live Preview of the Content ## License diff --git a/package-lock.json b/package-lock.json index fc6164e..922d196 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@contentstack/live-preview-utils": "^2.0.2", + "@contentstack/utils": "^1.3.8", "@contentstack/venus-components": "^2.2.4", "@reduxjs/toolkit": "^2.2.1", "@testing-library/jest-dom": "^5.17.0", @@ -2036,9 +2037,9 @@ } }, "node_modules/@contentstack/utils": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/@contentstack/utils/-/utils-1.3.3.tgz", - "integrity": "sha512-Zj2ejyfbxZlXrF1Wl9lhwK2mCCWo5ooiDnSlNA8nupZ1nDsTfouYERgps8r/uyzm18Vda2wBitxloThxKAyzsA==" + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/@contentstack/utils/-/utils-1.3.8.tgz", + "integrity": "sha512-BKZcZs2/odh9nmugLmiNVBEbz34gjfgibZOsRlYV9ux7t+GkfjbELDjWJpKenL6G5Mb270VXVuDbNqkDLK96Zw==" }, "node_modules/@contentstack/venus-components": { "version": "2.2.4", diff --git a/package.json b/package.json index 24022c9..3ae79df 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "author": "Contentstack", "dependencies": { "@contentstack/live-preview-utils": "^2.0.2", + "@contentstack/utils": "^1.3.8", "@contentstack/venus-components": "^2.2.4", "@reduxjs/toolkit": "^2.2.1", "@testing-library/jest-dom": "^5.17.0", diff --git a/src/api/index.ts b/src/api/index.ts index 6d5b6bb..a1f88f1 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -8,6 +8,7 @@ import { } from "../reducer"; import { initializeContentstackSdk } from "../sdk/utils"; import * as Utils from "@contentstack/utils"; +import { addEditableTags } from "@contentstack/utils"; const Stack = initializeContentstackSdk(); @@ -67,6 +68,7 @@ export const fetchHeaderData = async ( dispatch: Dispatch ): Promise => { const data = await getEntry(CONTENT_TYPES.HEADER); + addEditableTags(data[0][0], CONTENT_TYPES.HEADER, true, "en-us"); dispatch(setHeaderData(data[0][0])); }; @@ -74,6 +76,7 @@ export const fetchFooterData = async ( dispatch: Dispatch ): Promise => { const data = await getEntry(CONTENT_TYPES.FOOTER); + addEditableTags(data[0][0], CONTENT_TYPES.FOOTER, true, "en-us"); dispatch(setFooterData(data[0][0])); }; @@ -86,6 +89,7 @@ export const fetchHomePageData = async ( referenceFieldPath: undefined, jsonRtePath: undefined, }); + addEditableTags(data[0], CONTENT_TYPES.PAGE, true, "en-us"); dispatch(setHomePageData(data[0])); }; @@ -115,6 +119,7 @@ export const fetchMenuPageData = async ( referenceFieldPath: ["sections.menu.course.dishes"], jsonRtePath: undefined, }); + addEditableTags(data[0], CONTENT_TYPES.PAGE, true, "en-us"); dispatch(setMenuPageData(data[0].sections[0].menu.course)); setLoading(false); }; diff --git a/src/components/footer/Footer.tsx b/src/components/footer/Footer.tsx index 9076deb..9c7e599 100644 --- a/src/components/footer/Footer.tsx +++ b/src/components/footer/Footer.tsx @@ -13,10 +13,10 @@ const Footer: React.FC = () => {
{navigation_links && (
-

{navigation_links?.title}

+

{navigation_links?.title}

-

{copyright}

+

{copyright}

); }; diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index 940720e..2caa41a 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -18,12 +18,13 @@ const Header: React.FC = () => {
- Logo + Logo