Skip to content

Commit 2cdd078

Browse files
feat: bump makeswift runtime to 0.24.0, simplify implementation (#2252)
Co-authored-by: Nathan Booker <nathan.booker@bigcommerce.com>
1 parent 8e8b31c commit 2cdd078

File tree

6 files changed

+29
-35
lines changed

6 files changed

+29
-35
lines changed

.changeset/shiny-worlds-type.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@bigcommerce/catalyst-core": patch
3+
---
4+
5+
fix: bump makeswift runtime version to `v0.24.0`, fixing issue with editing on SSGd pages

core/app/[locale]/layout.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { DraftModeScript } from '@makeswift/runtime/next/server';
21
import { Analytics } from '@vercel/analytics/react';
32
import { SpeedInsights } from '@vercel/speed-insights/next';
43
import { clsx } from 'clsx';
@@ -105,7 +104,6 @@ export default async function RootLayout({ params, children }: Props) {
105104
<html className={clsx(fonts.map((f) => f.variable))} lang={locale}>
106105
<head>
107106
<SiteTheme />
108-
<DraftModeScript appOrigin={process.env.MAKESWIFT_APP_ORIGIN} />
109107
</head>
110108
<body>
111109
<NextIntlClientProvider locale={locale} messages={messages}>

core/middlewares/with-makeswift.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1-
import { unstable_createMakeswiftDraftRequest } from '@makeswift/runtime/next/middleware';
1+
import { unstable_isDraftModeRequest } from '@makeswift/runtime/next/middleware';
22

33
import { MiddlewareFactory } from './compose-middlewares';
44

5-
if (!process.env.MAKESWIFT_SITE_API_KEY) {
6-
throw new Error('MAKESWIFT_SITE_API_KEY is not set');
7-
}
8-
9-
const MAKESWIFT_SITE_API_KEY = process.env.MAKESWIFT_SITE_API_KEY;
10-
115
export const withMakeswift: MiddlewareFactory = (middleware) => {
126
return async (request, event) => {
13-
const draftRequest = await unstable_createMakeswiftDraftRequest(
14-
request,
15-
MAKESWIFT_SITE_API_KEY,
16-
);
7+
const isDraftRequest = unstable_isDraftModeRequest(request);
178

18-
if (draftRequest != null) {
9+
if (isDraftRequest) {
1910
// Makeswift Builder's locale switcher expects the host to derive locale strictly from
2011
// the URL. Disable cookie- and language-based locale detection when in draft mode to
2112
// meet this expectation.
22-
draftRequest.headers.set('x-bc-disable-locale-detection', 'true');
13+
request.headers.set('x-bc-disable-locale-detection', 'true');
2314

24-
return await middleware(draftRequest, event);
15+
return await middleware(request, event);
2516
}
2617

2718
return middleware(request, event);

core/next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { client } from './client';
88
import { graphql } from './client/graphql';
99
import { cspHeader } from './lib/content-security-policy';
1010

11-
const withMakeswift = createWithMakeswift({ previewMode: false });
11+
const withMakeswift = createWithMakeswift();
1212
const withNextIntl = createNextIntlPlugin();
1313

1414
const LocaleQuery = graphql(`

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@conform-to/react": "^1.3.0",
1818
"@conform-to/zod": "^1.3.0",
1919
"@icons-pack/react-simple-icons": "^11.2.0",
20-
"@makeswift/runtime": "^0.23.11",
20+
"@makeswift/runtime": "^0.24.0",
2121
"@radix-ui/react-accordion": "^1.2.3",
2222
"@radix-ui/react-alert-dialog": "^1.1.6",
2323
"@radix-ui/react-checkbox": "^1.1.4",

pnpm-lock.yaml

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)