Переглянути джерело

feat: draw the link preview like the hero card

The Open Graph image still had the first redesign's look: a plain sans
headline and a flat cyan name. It now matches the site: the light glass
card, the headline in Fraunces at its soft settings, "Eric" in the
italic with the glacier-to-ember gradient, and the glass period on the
baseline. The fonts are static Latin subsets in assets/fonts/og (OFL),
so the image builds without fetching anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEPoSHwHCYMNpm2iKxY9hL
Claude 1 місяць тому
батько
коміт
f11071f96c

+ 118 - 34
app/opengraph-image.tsx

@@ -1,3 +1,6 @@
+import { readFile } from "node:fs/promises";
+import { join } from "node:path";
+
 import { ImageResponse } from "next/og";
 
 export const alt =
@@ -5,61 +8,142 @@ export const alt =
 export const size = { width: 1200, height: 630 };
 export const contentType = "image/png";
 
-export default function Image() {
+// Static cuts of the site's faces (Latin subsets, OFL): Fraunces at the
+// headline's soft settings (SOFT 100, opsz 144) and Figtree for the text.
+const font = (file: string) =>
+  readFile(join(process.cwd(), "assets/fonts/og", file));
+
+const INK = "#17161b";
+const MUTED = "#6c6874";
+// The name's glacier-to-ember gradient, mixed in oklab like the site's.
+const NAME =
+  "#2a86dd 5%, #707ec5 27.5%, #9972ad 50%, #bb6294 72.5%, #d9487a 95%";
+
+/** The hero card as a link preview: headline, glass period, and bio. */
+export default async function Image() {
+  const [display, displayItalic, text, textBold] = await Promise.all([
+    font("fraunces-600-soft.ttf"),
+    font("fraunces-600-soft-italic.ttf"),
+    font("figtree-400.ttf"),
+    font("figtree-600.ttf"),
+  ]);
+
   return new ImageResponse(
     <div
       style={{
-        background:
-          "radial-gradient(circle at 18% 12%, rgba(40,120,200,0.45), transparent 55%), radial-gradient(circle at 92% 100%, rgba(255,120,70,0.28), transparent 50%), #05070b",
         width: "100%",
         height: "100%",
         display: "flex",
-        flexDirection: "column",
-        justifyContent: "space-between",
-        padding: "72px 80px",
-        fontFamily: "sans-serif",
-        color: "#e8eef7",
+        padding: 44,
+        background:
+          "radial-gradient(circle at 0% 0%, rgba(42,134,221,0.22), transparent 58%), radial-gradient(circle at 100% 100%, rgba(217,72,122,0.18), transparent 55%), #f6f2f2",
+        fontFamily: "Figtree",
+        color: INK,
       }}
     >
       <div
         style={{
+          flex: 1,
           display: "flex",
-          fontSize: 22,
-          letterSpacing: 4,
-          color: "#8592a8",
+          flexDirection: "column",
+          justifyContent: "space-between",
+          padding: "52px 64px 58px",
+          borderRadius: 44,
+          background: "rgba(255,255,255,0.66)",
+          border: "1.5px solid rgba(255,255,255,0.9)",
+          boxShadow:
+            "0 30px 60px -30px rgba(23,22,27,0.28), 0 2px 8px -2px rgba(23,22,27,0.06)",
         }}
       >
-        SEATTLE, WA · 47.61° N
-      </div>
-      <div style={{ display: "flex", flexDirection: "column", gap: 18 }}>
         <div
           style={{
             display: "flex",
-            fontSize: 104,
-            fontWeight: 700,
-            letterSpacing: -4,
-            lineHeight: 1,
+            alignItems: "center",
+            justifyContent: "space-between",
           }}
         >
-          Hey, I&apos;m{" "}
-          <span style={{ color: "#5cc8ff", marginLeft: 24 }}>Eric.</span>
+          <div style={{ display: "flex", flexDirection: "column", gap: 4 }}>
+            <span style={{ fontSize: 30, fontWeight: 600 }}>Eric Wu</span>
+            <span style={{ fontSize: 24, color: MUTED }}>Seattle, WA</span>
+          </div>
+          <span
+            style={{
+              fontSize: 24,
+              fontWeight: 600,
+              padding: "12px 26px",
+              borderRadius: 999,
+              background: "rgba(255,255,255,0.9)",
+              boxShadow: "0 8px 22px -12px rgba(23,22,27,0.35)",
+            }}
+          >
+            ericwu.me
+          </span>
         </div>
-        <div style={{ display: "flex", fontSize: 36, color: "#b7c3d4" }}>
-          SDE II at AWS · agentic systems &amp; generative UI
+
+        <div
+          style={{
+            display: "flex",
+            alignItems: "baseline",
+            fontFamily: "Fraunces",
+            fontSize: 156,
+            fontWeight: 600,
+            letterSpacing: -3.5,
+            lineHeight: 1,
+          }}
+        >
+          <span>Hey, I&apos;m</span>
+          <span
+            style={{
+              marginLeft: 38,
+              paddingRight: 8,
+              fontStyle: "italic",
+              backgroundImage: `linear-gradient(100deg, ${NAME})`,
+              backgroundClip: "text",
+              color: "transparent",
+            }}
+          >
+            Eric
+          </span>
+          {/* The glass period, resting on the baseline as it does in light mode. */}
+          <div
+            style={{
+              display: "flex",
+              position: "relative",
+              top: -19,
+              width: 32,
+              height: 32,
+              borderRadius: 999,
+              background:
+                "radial-gradient(circle at 34% 30%, #6a717d 0%, #23262d 46%, #08090b 100%)",
+              boxShadow: "0 7px 12px -6px rgba(0,0,0,0.45)",
+            }}
+          >
+            <div
+              style={{
+                position: "absolute",
+                top: 6,
+                left: 8,
+                width: 11,
+                height: 7,
+                borderRadius: 999,
+                background: "rgba(255,255,255,0.75)",
+              }}
+            />
+          </div>
         </div>
-      </div>
-      <div
-        style={{
-          display: "flex",
-          justifyContent: "space-between",
-          fontSize: 24,
-          color: "#8592a8",
-        }}
-      >
-        <span>ericwu.me</span>
-        <span style={{ color: "#ff8a5b" }}>▲ Rainier 2027</span>
+        <span style={{ fontSize: 34, lineHeight: 1.35, color: MUTED }}>
+          An SDE II at AWS building agentic systems and generative UI.
+        </span>
       </div>
     </div>,
-    { ...size },
+    {
+      ...size,
+      fonts: [
+        { name: "Fraunces", data: display, weight: 600, style: "normal" },
+        { name: "Fraunces", data: displayItalic, weight: 600, style: "italic" },
+        { name: "Figtree", data: text, weight: 400, style: "normal" },
+        { name: "Figtree", data: textBold, weight: 600, style: "normal" },
+      ],
+    },
   );
 }

+ 94 - 0
assets/fonts/og/OFL.txt

@@ -0,0 +1,94 @@
+Copyright 2018 The Fraunces Project Authors (https://github.com/undercasetype/Fraunces)
+Copyright 2022 The Figtree Project Authors (https://github.com/erikdkennedy/figtree)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded, 
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.

BIN
assets/fonts/og/figtree-400.ttf


BIN
assets/fonts/og/figtree-600.ttf


BIN
assets/fonts/og/fraunces-600-soft-italic.ttf


BIN
assets/fonts/og/fraunces-600-soft.ttf