Skip to content

Commit e971d98

Browse files
authored
Update Next.js to 15.2 and fix social cards (#4387)
1 parent b5be418 commit e971d98

File tree

9 files changed

+145
-127
lines changed

9 files changed

+145
-127
lines changed

Dockerfile.node.local

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:23
1+
FROM node:23.9.0
22

33
WORKDIR /home/node/app
44

frontend/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@python-italia/pycon-styleguide": "0.1.210",
2828
"@sentry/nextjs": "^8.45.0",
2929
"@vercel/analytics": "^1.1.1",
30-
"@vercel/og": "^0.6.2",
30+
"@vercel/og": "^0.6.5",
3131
"@vercel/speed-insights": "^1.0.12",
3232
"@xstate/react": "^3.0.1",
3333
"clsx": "^1.2.1",
@@ -42,7 +42,7 @@
4242
"graphql-tag": "^2.12.6",
4343
"marksy": "^8.0.0",
4444
"moment": "^2.29.1",
45-
"next": "15.1.0",
45+
"next": "15.2.0",
4646
"next-cookies": "^2.0.3",
4747
"pdfkit": "^0.15.1",
4848
"react": "19.0.0",

frontend/pnpm-lock.yaml

+74-67
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/pages/api/[lang]/event/[slug]/social-card.tsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ export const config = {
1111
unstable_allowDynamic: ["/node_modules/.pnpm/**"],
1212
};
1313

14-
const regularFont = fetch(
15-
new URL(
16-
"../../../../../social-card-font/GeneralSans-Regular.otf",
17-
import.meta.url,
18-
),
19-
).then((res) => res.arrayBuffer());
20-
const semiBoldFont = fetch(
21-
new URL(
22-
"../../../../../social-card-font/GeneralSans-Semibold.otf",
23-
import.meta.url,
24-
),
25-
).then((res) => res.arrayBuffer());
26-
2714
export const handler = async (req: NextRequest) => {
15+
const regularFont = fetch(
16+
new URL(
17+
"./social-card-font/GeneralSans-Regular.otf",
18+
req.url.substring(0, req.url.lastIndexOf("/api")),
19+
),
20+
).then((res) => res.arrayBuffer());
21+
const semiBoldFont = fetch(
22+
new URL(
23+
"./social-card-font/GeneralSans-Semibold.otf",
24+
req.url.substring(0, req.url.lastIndexOf("/api")),
25+
),
26+
).then((res) => res.arrayBuffer());
27+
2828
const client = createClient();
2929
const { searchParams } = new URL(req.url);
3030

frontend/src/pages/api/[lang]/keynotes/[slug]/social-card.tsx

+17-15
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,24 @@ export const config = {
1111
unstable_allowDynamic: ["/node_modules/.pnpm/**"],
1212
};
1313

14-
const regularFont = fetch(
15-
new URL(
16-
"../../../../../social-card-font/GeneralSans-Regular.otf",
17-
import.meta.url,
18-
),
19-
).then((res) => res.arrayBuffer());
20-
const semiBoldFont = fetch(
21-
new URL(
22-
"../../../../../social-card-font/GeneralSans-Semibold.otf",
23-
import.meta.url,
24-
),
25-
).then((res) => res.arrayBuffer());
26-
2714
export const handler = async (req: NextRequest) => {
28-
const regularFontData = await regularFont;
29-
const semiBoldFontData = await semiBoldFont;
15+
const regularFont = fetch(
16+
new URL(
17+
"./social-card-font/GeneralSans-Regular.otf",
18+
req.url.substring(0, req.url.lastIndexOf("/api")),
19+
),
20+
).then((res) => res.arrayBuffer());
21+
const semiBoldFont = fetch(
22+
new URL(
23+
"./social-card-font/GeneralSans-Semibold.otf",
24+
req.url.substring(0, req.url.lastIndexOf("/api")),
25+
),
26+
).then((res) => res.arrayBuffer());
27+
28+
const [regularFontData, semiBoldFontData] = await Promise.all([
29+
regularFont,
30+
semiBoldFont,
31+
]);
3032
const client = createClient();
3133
const { searchParams } = new URL(req.url);
3234

frontend/src/pages/api/[lang]/news/[slug]/social-card.tsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ export const config = {
1111
unstable_allowDynamic: ["/node_modules/.pnpm/**"],
1212
};
1313

14-
const regularFont = fetch(
15-
new URL(
16-
"../../../../../social-card-font/GeneralSans-Regular.otf",
17-
import.meta.url,
18-
),
19-
).then((res) => res.arrayBuffer());
20-
const semiBoldFont = fetch(
21-
new URL(
22-
"../../../../../social-card-font/GeneralSans-Semibold.otf",
23-
import.meta.url,
24-
),
25-
).then((res) => res.arrayBuffer());
26-
2714
const handler = async (req: NextRequest) => {
15+
const regularFont = fetch(
16+
new URL(
17+
"./social-card-font/GeneralSans-Regular.otf",
18+
req.url.substring(0, req.url.lastIndexOf("/api")),
19+
),
20+
).then((res) => res.arrayBuffer());
21+
const semiBoldFont = fetch(
22+
new URL(
23+
"./social-card-font/GeneralSans-Semibold.otf",
24+
req.url.substring(0, req.url.lastIndexOf("/api")),
25+
),
26+
).then((res) => res.arrayBuffer());
27+
2828
const client = createClient();
2929
const { searchParams } = new URL(req.url);
3030

frontend/src/pages/api/[lang]/social-card.tsx

+25-16
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@ export const config = {
1212
unstable_allowDynamic: ["/node_modules/.pnpm/**"],
1313
};
1414

15-
const regularFont = fetch(
16-
new URL("../../../social-card-font/GeneralSans-Regular.otf", import.meta.url),
17-
).then((res) => res.arrayBuffer());
18-
const semiBoldFont = fetch(
19-
new URL(
20-
"../../../social-card-font/GeneralSans-Semibold.otf",
21-
import.meta.url,
22-
),
23-
).then((res) => res.arrayBuffer());
24-
const mainIllustration = fetch(
25-
new URL("../../../../public/images/main-illustration.png", import.meta.url),
26-
).then((res) => res.arrayBuffer());
27-
2815
const getDays = ({ start, end }: { start: string; end: string }) => {
2916
// assuming the same month
3017
const startDate = new Date(start);
@@ -50,6 +37,25 @@ const getYear = ({ end }: { end: string }) => {
5037
};
5138

5239
const handler = async (req: NextRequest) => {
40+
const regularFont = fetch(
41+
new URL(
42+
"./social-card-font/GeneralSans-Regular.otf",
43+
req.url.substring(0, req.url.lastIndexOf("/api")),
44+
),
45+
).then((res) => res.arrayBuffer());
46+
const semiBoldFont = fetch(
47+
new URL(
48+
"./social-card-font/GeneralSans-Semibold.otf",
49+
req.url.substring(0, req.url.lastIndexOf("/api")),
50+
),
51+
).then((res) => res.arrayBuffer());
52+
const mainIllustration = fetch(
53+
new URL(
54+
"./images/main-illustration.png",
55+
req.url.substring(0, req.url.lastIndexOf("/api")),
56+
),
57+
).then((res) => res.arrayBuffer());
58+
5359
const [regularFontData, semiBoldFontData, mainIllustrationData] =
5460
await Promise.all([regularFont, semiBoldFont, mainIllustration]);
5561
const client = createClient();
@@ -70,9 +76,12 @@ const handler = async (req: NextRequest) => {
7076
fontFamily: '"GeneralSans"',
7177
}}
7278
>
73-
{/* eslint-disable @typescript-eslint/ban-ts-comment */}
74-
{/* @ts-ignore */}
75-
<img width={600} height={"100%"} src={mainIllustrationData} alt="" />
79+
<img
80+
width={600}
81+
height={"100%"}
82+
src={mainIllustrationData as unknown as string}
83+
alt=""
84+
/>
7685
<div
7786
style={{
7887
display: "flex",

0 commit comments

Comments
 (0)