fix: cleanup after rebase
This commit is contained in:
6
env/schema.mjs
vendored
6
env/schema.mjs
vendored
@@ -10,11 +10,11 @@ export const serverSchema = z.object({
|
|||||||
CMS_API_KEY: z.string(),
|
CMS_API_KEY: z.string(),
|
||||||
CMS_ENVIRONMENT: z.enum(["development", "production", "staging", "test"]),
|
CMS_ENVIRONMENT: z.enum(["development", "production", "staging", "test"]),
|
||||||
CMS_URL: z.string(),
|
CMS_URL: z.string(),
|
||||||
CMS_PREVIEW_URL: z.string().optional(),
|
CMS_PREVIEW_URL: z.string(),
|
||||||
CMS_PREVIEW_TOKEN: z.string().optional(),
|
CMS_PREVIEW_TOKEN: z.string(),
|
||||||
NODE_ENV: z.enum(["development", "test", "production"]),
|
NODE_ENV: z.enum(["development", "test", "production"]),
|
||||||
PRINT_QUERY: z.boolean().default(false),
|
PRINT_QUERY: z.boolean().default(false),
|
||||||
});
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You can't destruct `process.env` as a regular object in the Next.js
|
* You can't destruct `process.env` as a regular object in the Next.js
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,30 +12,26 @@ export async function previewRequest<T>(
|
|||||||
variables?: {}
|
variables?: {}
|
||||||
): Promise<Data<T>> {
|
): Promise<Data<T>> {
|
||||||
try {
|
try {
|
||||||
const hash = ContentstackLivePreview.hash;
|
const hash = ContentstackLivePreview.hash
|
||||||
|
|
||||||
if (!hash) {
|
if (!hash) {
|
||||||
throw new Error("No hash received");
|
throw new Error("No hash received")
|
||||||
}
|
|
||||||
|
|
||||||
if (!env.CMS_PREVIEW_URL || !env.CMS_PREVIEW_TOKEN) {
|
|
||||||
throw new Error("No preview URL or token");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const headers = new Headers({
|
const headers = new Headers({
|
||||||
access_token: env.CMS_ACCESS_TOKEN,
|
access_token: env.CMS_ACCESS_TOKEN,
|
||||||
preview_token: env.CMS_PREVIEW_TOKEN,
|
preview_token: env.CMS_PREVIEW_TOKEN,
|
||||||
live_preview: hash,
|
live_preview: hash,
|
||||||
});
|
})
|
||||||
|
|
||||||
const response = await graphqlRequest<T>({
|
const response = await graphqlRequest<T>({
|
||||||
document: query,
|
document: query,
|
||||||
requestHeaders: headers,
|
requestHeaders: headers,
|
||||||
url: env.CMS_PREVIEW_URL,
|
url: env.CMS_PREVIEW_URL,
|
||||||
variables,
|
variables,
|
||||||
});
|
})
|
||||||
|
|
||||||
return { data: response };
|
return { data: response }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
throw new Error("Something went wrong");
|
throw new Error("Something went wrong");
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -8,8 +8,8 @@
|
|||||||
"name": "web",
|
"name": "web",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"class-variance-authority": "^0.7.0",
|
|
||||||
"@contentstack/live-preview-utils": "^1.4.0",
|
"@contentstack/live-preview-utils": "^1.4.0",
|
||||||
|
"class-variance-authority": "^0.7.0",
|
||||||
"graphql": "16.8.1",
|
"graphql": "16.8.1",
|
||||||
"graphql-request": "6.1.0",
|
"graphql-request": "6.1.0",
|
||||||
"graphql-tag": "2.12.6",
|
"graphql-tag": "2.12.6",
|
||||||
|
|||||||
@@ -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">
|
|
||||||
Reference in New Issue
Block a user