Skip to content

Commit 92d0d1d

Browse files
committed
chore: prettier-format OG card files
1 parent 5bdff59 commit 92d0d1d

6 files changed

Lines changed: 686 additions & 141 deletions

File tree

app/(app)/s/[sourceSlug]/_sourceProfileClient.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const SourceProfileContent = ({ sourceSlug, initialProfile }: Props) => {
6565
// first render (including SSR) is the real profile rather than a skeleton.
6666
if (status === "error" || !pub) {
6767
return (
68-
<div className="mx-auto max-w-2xl px-0 py-4 sm:px-4 sm:py-8 text-fg">
68+
<div className="mx-auto max-w-2xl px-0 py-4 text-fg sm:px-4 sm:py-8">
6969
<div className="bg-danger/12 rounded-lg border border-danger/30 p-6 text-center">
7070
<h1 className="text-lg font-semibold text-danger">
7171
Publication Not Found

app/og/route.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,20 @@ async function logo(origin: string) {
3131
const res = await fetch(`${origin}/og/wordmark-white.png`);
3232
const bytes = new Uint8Array(await res.arrayBuffer());
3333
let binary = "";
34-
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
34+
for (let i = 0; i < bytes.length; i++)
35+
binary += String.fromCharCode(bytes[i]);
3536
return (_logo = `data:image/png;base64,${btoa(binary)}`);
3637
}
3738

3839
const list = (v: string | null) =>
39-
v ? v.split(",").map((s) => s.trim()).filter(Boolean) : undefined;
40-
const num = (v: string | null, d = 0) => (v != null && v !== "" ? Number(v) : d);
40+
v
41+
? v
42+
.split(",")
43+
.map((s) => s.trim())
44+
.filter(Boolean)
45+
: undefined;
46+
const num = (v: string | null, d = 0) =>
47+
v != null && v !== "" ? Number(v) : d;
4148

4249
export async function GET(req: Request) {
4350
try {

lib/og/fonts.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type FontSpec = {
77
name: string;
88
data: ArrayBuffer;
99
weight: 400 | 600 | 700 | 800;
10-
style: 'normal';
10+
style: "normal";
1111
};
1212

1313
// The css2 endpoint serves woff2 to modern UAs; spoofing an old UA makes it
@@ -18,31 +18,40 @@ export async function loadGoogleFont(
1818
text?: string,
1919
): Promise<ArrayBuffer> {
2020
const params = new URLSearchParams({ family: `${family}:wght@${weight}` });
21-
if (text) params.set('text', text);
21+
if (text) params.set("text", text);
2222
const cssUrl = `https://fonts.googleapis.com/css2?${params.toString()}`;
2323
const css = await fetch(cssUrl, {
24-
headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 5.1)' }, // old UA → ttf
24+
headers: { "User-Agent": "Mozilla/5.0 (Windows NT 5.1)" }, // old UA → ttf
2525
}).then((r) => r.text());
26-
const url = css.match(/src:\s*url\((.+?)\)\s*format\('(?:truetype|opentype)'\)/)?.[1];
26+
const url = css.match(
27+
/src:\s*url\((.+?)\)\s*format\('(?:truetype|opentype)'\)/,
28+
)?.[1];
2729
if (!url) throw new Error(`Could not resolve a TTF for ${family} ${weight}`);
2830
return fetch(url).then((r) => r.arrayBuffer());
2931
}
3032

3133
// Load everything Codú OG cards need. Pass it the text you're about to
3234
// render to subset aggressively (smaller payloads); omit for full sets.
3335
export async function coduFonts(text?: string): Promise<FontSpec[]> {
34-
const [bricolage, hanken400, hanken600, mono400, mono600] = await Promise.all([
35-
loadGoogleFont('Bricolage Grotesque', 800, text),
36-
loadGoogleFont('Hanken Grotesk', 400, text),
37-
loadGoogleFont('Hanken Grotesk', 600, text),
38-
loadGoogleFont('JetBrains Mono', 400, text),
39-
loadGoogleFont('JetBrains Mono', 600, text),
40-
]);
36+
const [bricolage, hanken400, hanken600, mono400, mono600] = await Promise.all(
37+
[
38+
loadGoogleFont("Bricolage Grotesque", 800, text),
39+
loadGoogleFont("Hanken Grotesk", 400, text),
40+
loadGoogleFont("Hanken Grotesk", 600, text),
41+
loadGoogleFont("JetBrains Mono", 400, text),
42+
loadGoogleFont("JetBrains Mono", 600, text),
43+
],
44+
);
4145
return [
42-
{ name: 'Bricolage Grotesque', data: bricolage, weight: 800, style: 'normal' },
43-
{ name: 'Hanken Grotesk', data: hanken400, weight: 400, style: 'normal' },
44-
{ name: 'Hanken Grotesk', data: hanken600, weight: 600, style: 'normal' },
45-
{ name: 'JetBrains Mono', data: mono400, weight: 400, style: 'normal' },
46-
{ name: 'JetBrains Mono', data: mono600, weight: 600, style: 'normal' },
46+
{
47+
name: "Bricolage Grotesque",
48+
data: bricolage,
49+
weight: 800,
50+
style: "normal",
51+
},
52+
{ name: "Hanken Grotesk", data: hanken400, weight: 400, style: "normal" },
53+
{ name: "Hanken Grotesk", data: hanken600, weight: 600, style: "normal" },
54+
{ name: "JetBrains Mono", data: mono400, weight: 400, style: "normal" },
55+
{ name: "JetBrains Mono", data: mono600, weight: 600, style: "normal" },
4756
];
4857
}

0 commit comments

Comments
 (0)