Skip to content

Commit

Permalink
chore: execute next 15 update using @next/codemod@canary
Browse files Browse the repository at this point in the history
  • Loading branch information
robp committed Nov 7, 2024
1 parent 4afd7f6 commit eba76db
Show file tree
Hide file tree
Showing 6 changed files with 1,017 additions and 365 deletions.
12 changes: 7 additions & 5 deletions app/[locale]/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getLocaleFromPath } from '#/locales/get-locale-from-path';
import { getStaticParams } from '#/locales/server';

type PageProps = {
params: { slug: string[]; locale: string };
params: Promise<{ slug: string[]; locale: string }>;
};

const getPage = async (slug: string, locale: string, preview = false) => {
Expand Down Expand Up @@ -123,12 +123,13 @@ const getPageMetadata = async (slug: string, locale: string, preview = false): P
};
};

export default async function LandingPage({ params }: PageProps) {
export default async function LandingPage(props: PageProps) {
const params = await props.params;
const { locale } = params;
setStaticParamsLocale(locale);
const slug = params.slug?.join('/') ?? 'home';

const { isEnabled: isDraftMode } = draftMode();
const { isEnabled: isDraftMode } = await draftMode();

const pageData = await getPage(slug, getLocaleFromPath(locale), isDraftMode);

Expand All @@ -154,10 +155,11 @@ export default async function LandingPage({ params }: PageProps) {
);
}

export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
export async function generateMetadata(props: PageProps): Promise<Metadata> {
const params = await props.params;
const { locale } = params;
const slug = params.slug?.join('/') ?? 'home';
const { isEnabled: isDraftMode } = draftMode();
const { isEnabled: isDraftMode } = await draftMode();
return getPageMetadata(slug, getLocaleFromPath(locale), isDraftMode);
}

Expand Down
14 changes: 6 additions & 8 deletions app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ import { fontSans } from '#/lib/fonts';
import { cn } from '#/lib/utils';
import { getLocaleFromPath } from '#/locales/get-locale-from-path';

export default async function RootLayout({
children,
params,
}: {
children: React.ReactNode;
params: { locale: string };
}) {
export default async function RootLayout(props: { children: React.ReactNode; params: Promise<{ locale: string }> }) {
const params = await props.params;

const { children } = props;

const shouldInjectToolbar = process.env.NODE_ENV === 'development';
const { locale } = params;
const { isEnabled: isDraftMode } = draftMode();
const { isEnabled: isDraftMode } = await draftMode();

const layoutQuery = graphql(
`
Expand Down
6 changes: 3 additions & 3 deletions app/api/disable-draft/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { cookies, draftMode } from 'next/headers';
import { redirect } from 'next/navigation';

export async function GET() {
draftMode().disable();
(await draftMode()).disable();

// Set __prerender_bypass expire date to past.
if (process.env.NODE_ENV === 'development') {
const cookieStore = cookies();
const cookieStore = await cookies();
const cookie = cookieStore.get('__prerender_bypass')!;
cookies().set({
(await cookies()).set({
name: '__prerender_bypass',
value: cookie?.value,
expires: new Date(0), // Set expiration date to the past
Expand Down
6 changes: 3 additions & 3 deletions app/api/draft/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ export async function GET(request: Request) {
}

// Enable Draft Mode by setting the cookie
draftMode().enable();
(await draftMode()).enable();

// Set the __prerender_bypass as secure for local environment.
// Will work only in next dev mode.
// https://github.com/vercel/next.js/issues/49927
if (process.env.NODE_ENV === 'development') {
const cookieStore = cookies();
const cookieStore = await cookies();
const cookie = cookieStore.get('__prerender_bypass');
cookies().set({
(await cookies()).set({
name: '__prerender_bypass',
value: cookie?.value || '',
httpOnly: true,
Expand Down
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"prepare": "husky install",
"postinstall": "husky install",
"dev": "next dev",
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint",
Expand All @@ -35,8 +35,8 @@
"@radix-ui/react-slot": "^1.0.2",
"@storybook/test": "^8.0.4",
"@types/node": "18.11.11",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]",
"@urql/exchange-persisted": "^4.2.0",
"@vercel/toolbar": "^0.1.22",
"analytics": "^0.8.11",
Expand All @@ -47,10 +47,10 @@
"graphql": "^16.8.1",
"graphql-request": "^6.1.0",
"lucide-react": "^0.368.0",
"next": "14.2.7",
"next": "15.0.3",
"next-international": "^1.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "19.0.0-rc-66855b96-20241106",
"react-dom": "19.0.0-rc-66855b96-20241106",
"react-intersection-observer": "^9.8.1",
"server-only": "^0.0.1",
"tailwind-merge": "^1.14.0",
Expand Down Expand Up @@ -89,7 +89,7 @@
"cypress-image-snapshot": "^4.0.1",
"esbuild": "0.20.1",
"eslint": "^8.48.0",
"eslint-config-next": "^14.1.0",
"eslint-config-next": "15.0.3",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-storybook": "^0.8.0",
Expand Down Expand Up @@ -122,7 +122,9 @@
},
"resolutions": {
"jackspeak": "2.1.1",
"@storybook/manager-webpack5/html-webpack-plugin": "^5.0.0"
"@storybook/manager-webpack5/html-webpack-plugin": "^5.0.0",
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]"
},
"packageManager": "[email protected]"
}
Loading

0 comments on commit eba76db

Please sign in to comment.