Skip to content

Commit 4f1d31a

Browse files
committed
feat: enables client-side navigation in Makeswift builder
Enabled by upgrading to the latest Makeswift runtime
1 parent e290dd1 commit 4f1d31a

7 files changed

Lines changed: 46 additions & 48 deletions

File tree

core/app/[locale]/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export default async function RootLayout({ params, children }: Props) {
129129
const privacyPolicyUrl = rootData.data.site.settings?.privacy?.privacyPolicyUrl;
130130

131131
return (
132-
<MakeswiftProvider siteVersion={siteVersion}>
132+
<MakeswiftProvider siteVersion={siteVersion} locale={locale}>
133133
<html className={clsx(fonts.map((f) => f.variable))} lang={locale}>
134134
<head>
135135
<SiteTheme />

core/app/api/makeswift/[...makeswift]/route.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ const defaultVariants: Font['variants'] = [
2424

2525
const handler = MakeswiftApiHandler(process.env.MAKESWIFT_SITE_API_KEY, {
2626
runtime,
27-
apiOrigin: process.env.NEXT_PUBLIC_MAKESWIFT_API_ORIGIN ?? process.env.MAKESWIFT_API_ORIGIN,
28-
appOrigin: process.env.NEXT_PUBLIC_MAKESWIFT_APP_ORIGIN ?? process.env.MAKESWIFT_APP_ORIGIN,
2927
getFonts() {
3028
return [
3129
{

core/lib/makeswift/client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ strict(process.env.MAKESWIFT_SITE_API_KEY, 'MAKESWIFT_SITE_API_KEY is required')
1111

1212
export const client = new Makeswift(process.env.MAKESWIFT_SITE_API_KEY, {
1313
runtime,
14-
apiOrigin: process.env.NEXT_PUBLIC_MAKESWIFT_API_ORIGIN ?? process.env.MAKESWIFT_API_ORIGIN,
1514
});
1615

1716
export const getPageSnapshot = async ({ path, locale }: { path: string; locale: string }) =>

core/lib/makeswift/provider.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,15 @@ import '~/lib/makeswift/components';
77

88
export function MakeswiftProvider({
99
children,
10+
locale,
1011
siteVersion,
1112
}: {
1213
children: React.ReactNode;
14+
locale: string;
1315
siteVersion: SiteVersion | null;
1416
}) {
1517
return (
16-
<ReactRuntimeProvider
17-
apiOrigin={process.env.NEXT_PUBLIC_MAKESWIFT_API_ORIGIN}
18-
appOrigin={process.env.NEXT_PUBLIC_MAKESWIFT_APP_ORIGIN}
19-
runtime={runtime}
20-
siteVersion={siteVersion}
21-
>
18+
<ReactRuntimeProvider runtime={runtime} locale={locale} siteVersion={siteVersion}>
2219
<RootStyleRegistry enableCssReset={false}>{children}</RootStyleRegistry>
2320
</ReactRuntimeProvider>
2421
);

core/lib/makeswift/runtime.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ import { registerSocialLinksComponent } from '@makeswift/runtime/react/builtins/
88
import { registerTextComponent } from '@makeswift/runtime/react/builtins/text';
99
import { registerVideoComponent } from '@makeswift/runtime/react/builtins/video';
1010
import { ReactRuntimeCore } from '@makeswift/runtime/react/core';
11+
import { fetch } from '@makeswift/runtime/next';
1112

1213
const runtime = new ReactRuntimeCore({
14+
apiOrigin: process.env.NEXT_PUBLIC_MAKESWIFT_API_ORIGIN,
15+
appOrigin: process.env.NEXT_PUBLIC_MAKESWIFT_APP_ORIGIN,
1316
breakpoints: {
1417
small: { width: 640, viewport: 390, label: 'Small' },
1518
medium: { width: 768, viewport: 765, label: 'Medium' },
1619
large: { width: 1024, viewport: 1000, label: 'Large' },
1720
screen: { width: 1280, label: 'XL' },
1821
},
22+
fetch,
1923
});
2024

2125
// Only register necessary built-in components. Omitted components are:

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@conform-to/react": "^1.6.1",
2020
"@conform-to/zod": "^1.6.1",
2121
"@icons-pack/react-simple-icons": "^11.2.0",
22-
"@makeswift/runtime": "^0.26.0",
22+
"@makeswift/runtime": "https://pkg.pr.new/makeswift/makeswift/@makeswift/runtime@1259",
2323
"@opentelemetry/api": "^1.9.0",
2424
"@opentelemetry/api-logs": "^0.208.0",
2525
"@opentelemetry/instrumentation": "^0.208.0",

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)