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

Fix social card not loading in prod #4330

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
26 changes: 13 additions & 13 deletions frontend/src/pages/api/[lang]/event/[slug]/social-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ export const config = {
unstable_allowDynamic: ["/node_modules/.pnpm/**"],
};

const regularFont = fetch(
new URL(
"../../../../../social-card-font/GeneralSans-Regular.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());
const semiBoldFont = fetch(
new URL(
"../../../../../social-card-font/GeneralSans-Semibold.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());

export const handler = async (req: NextRequest) => {
const regularFont = fetch(
new URL(
"../../../../../social-card-font/GeneralSans-Regular.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());
const semiBoldFont = fetch(
new URL(
"../../../../../social-card-font/GeneralSans-Semibold.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());

const client = createClient();
const { searchParams } = new URL(req.url);

Expand Down
26 changes: 13 additions & 13 deletions frontend/src/pages/api/[lang]/keynotes/[slug]/social-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ export const config = {
unstable_allowDynamic: ["/node_modules/.pnpm/**"],
};

const regularFont = fetch(
new URL(
"../../../../../social-card-font/GeneralSans-Regular.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());
const semiBoldFont = fetch(
new URL(
"../../../../../social-card-font/GeneralSans-Semibold.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());

export const handler = async (req: NextRequest) => {
const regularFont = fetch(
new URL(
"../../../../../social-card-font/GeneralSans-Regular.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());
const semiBoldFont = fetch(
new URL(
"../../../../../social-card-font/GeneralSans-Semibold.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());

const regularFontData = await regularFont;
const semiBoldFontData = await semiBoldFont;
const client = createClient();
Expand Down
26 changes: 13 additions & 13 deletions frontend/src/pages/api/[lang]/news/[slug]/social-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ export const config = {
unstable_allowDynamic: ["/node_modules/.pnpm/**"],
};

const regularFont = fetch(
new URL(
"../../../../../social-card-font/GeneralSans-Regular.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());
const semiBoldFont = fetch(
new URL(
"../../../../../social-card-font/GeneralSans-Semibold.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());

const handler = async (req: NextRequest) => {
const regularFont = fetch(
new URL(
"../../../../../social-card-font/GeneralSans-Regular.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());
const semiBoldFont = fetch(
new URL(
"../../../../../social-card-font/GeneralSans-Semibold.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());

const client = createClient();
const { searchParams } = new URL(req.url);

Expand Down
29 changes: 16 additions & 13 deletions frontend/src/pages/api/[lang]/social-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@ export const config = {
unstable_allowDynamic: ["/node_modules/.pnpm/**"],
};

const regularFont = fetch(
new URL("../../../social-card-font/GeneralSans-Regular.otf", import.meta.url),
).then((res) => res.arrayBuffer());
const semiBoldFont = fetch(
new URL(
"../../../social-card-font/GeneralSans-Semibold.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());
const mainIllustration = fetch(
new URL("../../../../public/images/main-illustration.png", import.meta.url),
).then((res) => res.arrayBuffer());

const getDays = ({ start, end }: { start: string; end: string }) => {
// assuming the same month
const startDate = new Date(start);
Expand All @@ -50,6 +37,22 @@ const getYear = ({ end }: { end: string }) => {
};

const handler = async (req: NextRequest) => {
const regularFont = fetch(
new URL(
"../../../social-card-font/GeneralSans-Regular.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());
const semiBoldFont = fetch(
new URL(
"../../../social-card-font/GeneralSans-Semibold.otf",
import.meta.url,
),
).then((res) => res.arrayBuffer());
const mainIllustration = fetch(
new URL("../../../../public/images/main-illustration.png", import.meta.url),
).then((res) => res.arrayBuffer());

const [regularFontData, semiBoldFontData, mainIllustrationData] =
await Promise.all([regularFont, semiBoldFont, mainIllustration]);
const client = createClient();
Expand Down