fix: cleanup after rebase

This commit is contained in:
Christel Westerberg
2024-02-12 14:04:53 +01:00
parent f7abe2c482
commit 2967f13921
5 changed files with 9 additions and 67 deletions

6
env/schema.mjs vendored
View File

@@ -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

View File

@@ -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
}
}
}
}
}
}
}

View File

@@ -12,30 +12,26 @@ export async function previewRequest<T>(
variables?: {}
): Promise<Data<T>> {
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<T>({
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");

2
package-lock.json generated
View File

@@ -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",

View File

@@ -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<Hero, "CurrentBlocksPageBlocksHero">