Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to Next 15 #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions apps/marketing/app/[locale]/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import { getLocaleFromPath } from '#/locales/get-locale-from-path';
import { getStaticParams } from '#/locales/server';

interface PageProps {
params: { slug?: string[]; locale: string };
params: Promise<Params>;
}

interface Params {
slug?: string[];
locale: string;
}

const getPage = async (slug: string, locale: string, preview = false) => {
Expand Down Expand Up @@ -136,12 +141,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 isDraftMode = (await draftMode()).isEnabled;

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

Expand All @@ -167,17 +173,18 @@ 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);
}

export async function generateStaticParams() {
// Teach Typescript what our locale segment name is.
const params = getStaticParams() as { locale: string }[];
const returnData: PageProps['params'][] = [];
const returnData: Params[] = [];
for await (const locale of params) {
const slugs = (await getPageSlugs(getLocaleFromPath(locale.locale))).map((page) => ({
slug: page.slug?.split('/'),
Expand Down
14 changes: 6 additions & 8 deletions apps/marketing/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ import { fontInter } from '#/lib/fonts';
import { cn } from '@repo/ui/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 isDraftMode = (await draftMode()).isEnabled;

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

export function GET() {
draftMode().disable();
export async function GET() {
(await draftMode()).disable();
// Set __prerender_bypass expire date to past.
if (process.env.NODE_ENV === 'development') {
cookies().set({
(await cookies()).set({
name: '__prerender_bypass',
value: '',
expires: new Date(0), // Set expiration date to the past
Expand Down
6 changes: 3 additions & 3 deletions apps/marketing/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
5 changes: 3 additions & 2 deletions apps/marketing/components/site-header/site-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { draftMode } from 'next/headers';
import { Navigation } from '#/components/navigation';

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: Fix fragment unmasking to type navigationData, if possible.
export function SiteHeader(props: { navigationData: any }) {
const { isEnabled: isDraftMode } = draftMode();
export async function SiteHeader(props: { navigationData: any }) {
const isDraftMode = (await draftMode()).isEnabled;

return (
<>
{isDraftMode && (
Expand Down
26 changes: 13 additions & 13 deletions apps/marketing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint",
Expand All @@ -17,13 +17,13 @@
},
"dependencies": {
"@contentful/content-source-maps": "^0.11.5",
"@contentful/live-preview": "^4.5.13",
"@contentful/rich-text-react-renderer": "^15.17.1",
"@contentful/live-preview": "^4.6.3",
"@contentful/rich-text-react-renderer": "^16.0.1",
"@contentful/rich-text-types": "^16.8.5",
"@inquirer/prompts": "^7.0.1",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-dialog": "^1.1.4",
"@radix-ui/react-navigation-menu": "^1.2.3",
"@radix-ui/react-slot": "^1.1.1",
"@repo/tailwind-config": "workspace:*",
"@repo/ui": "workspace:*",
"@urql/core": "^5.0.8",
Expand All @@ -35,12 +35,12 @@
"graphql": "^16.8.1",
"graphql-request": "^6.1.0",
"lodash": "^4.17.21",
"lucide-react": "^0.368.0",
"next": "14.2.7",
"lucide-react": "^0.468.0",
"next": "15.1.1",
"next-international": "^1.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intersection-observer": "^9.8.1",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-intersection-observer": "^9.14.0",
"server-only": "^0.0.1",
"tailwindcss-animate": "^1.0.6",
"typescript": "^5.4.3",
Expand All @@ -57,8 +57,8 @@
"@types/cypress-image-snapshot": "^3.1.6",
"@types/lodash": "^4.17.13",
"@types/node": "18.11.11",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@types/react": "19.0.1",
"@types/react-dom": "19.0.2",
"@types/use-analytics": "^0.0.3",
"autoprefixer": "^10.4.14",
"axe-core": "^4.6.1",
Expand Down
5 changes: 1 addition & 4 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module.exports = {
'**/*.(ts|tsx)': () => 'pnpm turbo run check-types',
'**/*.(ts|tsx|js)': (filenames) => [
`pnpm eslint ${filenames.join(' ')} --max-warnings=0`,
`pnpm prettier --write ${filenames.join(' ')}`,
],
'**/*.(ts|tsx|js)': (filenames) => [`pnpm lint`, `pnpm prettier --write ${filenames.join(' ')}`],
};
2 changes: 1 addition & 1 deletion packages/config-eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@typescript-eslint/parser": "^8.14.0",
"@vercel/style-guide": "^6.0.0",
"eslint": "^8.48.0",
"eslint-config-next": "^14.1.0",
"eslint-config-next": "^15.1.1",
"eslint-config-prettier": "^9.0.0",
"eslint-config-turbo": "^2.0.0",
"eslint-plugin-jsx-expressions": "^1.3.2",
Expand Down
16 changes: 8 additions & 8 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"lint": "eslint ."
},
"dependencies": {
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-dialog": "^1.1.4",
"@radix-ui/react-navigation-menu": "^1.2.3",
"@radix-ui/react-slot": "^1.1.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.368.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"lucide-react": "^0.468.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"tailwind-merge": "^1.14.0"
},
"devDependencies": {
Expand All @@ -29,8 +29,8 @@
"@storybook/addon-themes": "^8.4.4",
"@storybook/react": "^8.4.4",
"@storybook/react-vite": "^8.4.4",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.2",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.14",
"eslint": "^8.48.0",
Expand Down
Loading
Loading