opengraph-image.tsx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import { readFile } from "node:fs/promises";
  2. import { join } from "node:path";
  3. import { ImageResponse } from "next/og";
  4. export const alt = "邓康临 - Software Engineer";
  5. export const size = { width: 1200, height: 630 };
  6. export const contentType = "image/png";
  7. // Static cuts of the site's faces (Latin subsets, OFL): Fraunces at the
  8. // headline's soft settings (SOFT 100, opsz 144) and Figtree for the text.
  9. const font = (file: string) =>
  10. readFile(join(process.cwd(), "assets/fonts/og", file));
  11. const INK = "#17161b";
  12. const MUTED = "#6c6874";
  13. // The name's glacier-to-ember gradient, mixed in oklab like the site's.
  14. const NAME =
  15. "#2a86dd 5%, #707ec5 27.5%, #9972ad 50%, #bb6294 72.5%, #d9487a 95%";
  16. /** The hero card as a link preview: headline, glass period, and bio. */
  17. export default async function Image() {
  18. const [display, displayItalic, text, textBold] = await Promise.all([
  19. font("fraunces-600-soft.ttf"),
  20. font("fraunces-600-soft-italic.ttf"),
  21. font("figtree-400.ttf"),
  22. font("figtree-600.ttf"),
  23. ]);
  24. return new ImageResponse(
  25. <div
  26. style={{
  27. width: "100%",
  28. height: "100%",
  29. display: "flex",
  30. padding: 44,
  31. background:
  32. "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",
  33. fontFamily: "Figtree",
  34. color: INK,
  35. }}
  36. >
  37. <div
  38. style={{
  39. flex: 1,
  40. display: "flex",
  41. flexDirection: "column",
  42. justifyContent: "space-between",
  43. padding: "52px 64px 58px",
  44. borderRadius: 44,
  45. background: "rgba(255,255,255,0.66)",
  46. border: "1.5px solid rgba(255,255,255,0.9)",
  47. boxShadow:
  48. "0 30px 60px -30px rgba(23,22,27,0.28), 0 2px 8px -2px rgba(23,22,27,0.06)",
  49. }}
  50. >
  51. <div
  52. style={{
  53. display: "flex",
  54. alignItems: "center",
  55. justifyContent: "space-between",
  56. }}
  57. >
  58. <div style={{ display: "flex", flexDirection: "column", gap: 4 }}>
  59. {/* The OG bundle only ships Latin font subsets; use the romanised
  60. spelling here so the name renders instead of tofu boxes. */}
  61. <span style={{ fontSize: 30, fontWeight: 600 }}>Deng Kanglin</span>
  62. <span style={{ fontSize: 24, color: MUTED }}>Qingdao, China</span>
  63. </div>
  64. <span
  65. style={{
  66. fontSize: 24,
  67. fontWeight: 600,
  68. padding: "12px 26px",
  69. borderRadius: 999,
  70. background: "rgba(255,255,255,0.9)",
  71. boxShadow: "0 8px 22px -12px rgba(23,22,27,0.35)",
  72. }}
  73. >
  74. ericwu.me
  75. </span>
  76. </div>
  77. <div
  78. style={{
  79. display: "flex",
  80. alignItems: "baseline",
  81. fontFamily: "Fraunces",
  82. fontSize: 156,
  83. fontWeight: 600,
  84. letterSpacing: -3.5,
  85. lineHeight: 1,
  86. }}
  87. >
  88. <span>Hey, I&apos;m</span>
  89. <span
  90. style={{
  91. marginLeft: 38,
  92. paddingRight: 8,
  93. fontStyle: "italic",
  94. backgroundImage: `linear-gradient(100deg, ${NAME})`,
  95. backgroundClip: "text",
  96. color: "transparent",
  97. }}
  98. >
  99. {/* The OG bundle ships Latin subsets only and this 156px line was
  100. set to exactly four glyphs: keep the length so it can't overflow
  101. (the full name appears in the byline above). */}
  102. Deng
  103. </span>
  104. {/* The glass period, resting on the baseline as it does in light mode. */}
  105. <div
  106. style={{
  107. display: "flex",
  108. position: "relative",
  109. top: -19,
  110. width: 32,
  111. height: 32,
  112. borderRadius: 999,
  113. background:
  114. "radial-gradient(circle at 34% 30%, #6a717d 0%, #23262d 46%, #08090b 100%)",
  115. boxShadow: "0 7px 12px -6px rgba(0,0,0,0.45)",
  116. }}
  117. >
  118. <div
  119. style={{
  120. position: "absolute",
  121. top: 6,
  122. left: 8,
  123. width: 11,
  124. height: 7,
  125. borderRadius: 999,
  126. background: "rgba(255,255,255,0.75)",
  127. }}
  128. />
  129. </div>
  130. </div>
  131. <span style={{ fontSize: 34, lineHeight: 1.35, color: MUTED }}>
  132. An SDE II at AWS building agentic systems and generative UI.
  133. </span>
  134. </div>
  135. </div>,
  136. {
  137. ...size,
  138. fonts: [
  139. { name: "Fraunces", data: display, weight: 600, style: "normal" },
  140. { name: "Fraunces", data: displayItalic, weight: 600, style: "italic" },
  141. { name: "Figtree", data: text, weight: 400, style: "normal" },
  142. { name: "Figtree", data: textBold, weight: 600, style: "normal" },
  143. ],
  144. },
  145. );
  146. }