Skip to content

Commit 225630e

Browse files
authored
Merge pull request #16 from fived-studio/copilot/fix-error-after-merge-to-master
Stabilize member OG image generation by removing network-dependent diacritic rendering
2 parents 7d2f9a7 + 8c83a50 commit 225630e

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

app/m/[username]/opengraph-image.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export default async function OG({
4747

4848
const name = profile?.name ?? fallback.name;
4949
const role = profile?.role ?? fallback.role;
50+
const displayName = sanitizeForOGText(name);
51+
const displayRole = sanitizeForOGText(role);
5052

5153
return new ImageResponse(
5254
(
@@ -125,9 +127,9 @@ export default async function OG({
125127
color: "#ffffff",
126128
}}
127129
>
128-
{name}
130+
{displayName}
129131
</div>
130-
<div style={{ fontSize: 28, color: "#b8b3b0" }}>{role}</div>
132+
<div style={{ fontSize: 28, color: "#b8b3b0" }}>{displayRole}</div>
131133
<div
132134
style={{
133135
fontSize: 22,
@@ -171,6 +173,18 @@ export default async function OG({
171173
);
172174
}
173175

176+
/**
177+
* Strip combining diacritical marks (U+0300-U+036F) and map Đ/đ to ASCII
178+
* so Next.js OG generation does not trigger remote dynamic-font fetching.
179+
*/
180+
function sanitizeForOGText(value?: string | null) {
181+
return (value ?? "")
182+
.normalize("NFD")
183+
.replace(/[\u0300-\u036f]/g, "")
184+
.replace(/Đ/g, "D")
185+
.replace(/đ/g, "d");
186+
}
187+
174188
function Stat({ value, label }: { value: string; label: string }) {
175189
return (
176190
<div style={{ display: "flex", flexDirection: "column", gap: 4 }}>

0 commit comments

Comments
 (0)