diff --git a/env/schema.mjs b/env/schema.mjs index 5e9fd5895..c5917cb71 100644 --- a/env/schema.mjs +++ b/env/schema.mjs @@ -10,11 +10,11 @@ export const serverSchema = z.object({ CMS_API_KEY: z.string(), CMS_ENVIRONMENT: z.enum(["development", "production", "staging", "test"]), CMS_URL: z.string(), - CMS_PREVIEW_URL: z.string().optional(), - CMS_PREVIEW_TOKEN: z.string().optional(), + CMS_PREVIEW_URL: z.string(), + CMS_PREVIEW_TOKEN: z.string(), NODE_ENV: z.enum(["development", "test", "production"]), PRINT_QUERY: z.boolean().default(false), -}); +}) /** * You can't destruct `process.env` as a regular object in the Next.js diff --git a/lib/graphql/Fragments/Blocks/Hero.graphql b/lib/graphql/Fragments/Blocks/Hero.graphql deleted file mode 100644 index 5111ffc77..000000000 --- a/lib/graphql/Fragments/Blocks/Hero.graphql +++ /dev/null @@ -1,30 +0,0 @@ -#import "../PageLinks.graphql" - -fragment HeroBlock on CurrentBlocksPageBlocksHero { - hero { - imagesConnection { - totalCount - edges { - node { - title - url - } - } - } - ingress { - json - embedded_itemsConnection { - edges { - node { - ...CurrentBlocksPageLink - ...TempPageLink - ... on SysAsset { - title - url - } - } - } - } - } - } -} \ No newline at end of file diff --git a/lib/previewRequest.ts b/lib/previewRequest.ts index 392ca5f95..8f358878f 100644 --- a/lib/previewRequest.ts +++ b/lib/previewRequest.ts @@ -12,30 +12,26 @@ export async function previewRequest( variables?: {} ): Promise> { try { - const hash = ContentstackLivePreview.hash; + const hash = ContentstackLivePreview.hash if (!hash) { - throw new Error("No hash received"); - } - - if (!env.CMS_PREVIEW_URL || !env.CMS_PREVIEW_TOKEN) { - throw new Error("No preview URL or token"); + throw new Error("No hash received") } const headers = new Headers({ access_token: env.CMS_ACCESS_TOKEN, preview_token: env.CMS_PREVIEW_TOKEN, live_preview: hash, - }); + }) const response = await graphqlRequest({ document: query, requestHeaders: headers, url: env.CMS_PREVIEW_URL, variables, - }); + }) - return { data: response }; + return { data: response } } catch (error) { console.error(error); throw new Error("Something went wrong"); diff --git a/package-lock.json b/package-lock.json index fffc109ef..c393cc767 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,8 +8,8 @@ "name": "web", "version": "0.1.0", "dependencies": { - "class-variance-authority": "^0.7.0", "@contentstack/live-preview-utils": "^1.4.0", + "class-variance-authority": "^0.7.0", "graphql": "16.8.1", "graphql-request": "6.1.0", "graphql-tag": "2.12.6", diff --git a/types/requests/blocks/hero.ts b/types/requests/blocks/hero.ts deleted file mode 100644 index be8b1bbb2..000000000 --- a/types/requests/blocks/hero.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { SysAsset } from "../utils/asset" -import type { Edges } from "../utils/edges" -import type { ExternalLink } from "../utils/externalLink" -import type { PageLink } from "../utils/pageLink"; -import type { Typename } from "../utils/typename" - -export type Hero = { - hero: { - imagesConnection: Edges<{ - title: string - url: string - }> - ingress: { - json: JSON - embedded_itemsConnection: Edges< - | ExternalLink - | PageLink - | SysAsset - > - } - } -} - -export type HeroBlockData = Typename