SPB Git

Repository Public

og.tsx 4.4 KB 82 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : ORIX App Universe8 * File             : src/lib/og.tsx9 * Module           : lib10 * Repository       : https://git.spboucher.ai/orix-spboucher-ai11 * Project Website  : https://www.orixlab.dev12 * Created          : 2026-11-2113 * Last Modified    : 2026-11-2114 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243import { readFile } from "node:fs/promises";44import { join } from "node:path";45import { ImageResponse } from "next/og";46import { env } from "./env";4748export const OG_SIZE = { width: 1200, height: 630 };4950async function dataUrl(slug: string, icon: string | null): Promise<string | null> {51  if (!icon) return null;52  const path = icon.startsWith("u/") ? join(env.dataDir, "uploads", slug, icon.slice(2)) : join(process.cwd(), "public/apps", slug, icon);53  try { return `data:image/png;base64,${(await readFile(path)).toString("base64")}`; } catch { return null; }54}5556/** Social preview card: the ORIX mark, a title, a line of text and (for an application) its real icon. */57export async function ogCard(o: { title: string; subtitle: string; kicker: string; slug?: string; icon?: string | null; accent?: string | null }) {58  const icon = o.slug ? await dataUrl(o.slug, o.icon ?? null) : null;59  const accent = o.accent ?? "#8F6BFF";60  return new ImageResponse(61    (62      <div style={{ width: "100%", height: "100%", display: "flex", flexDirection: "column", justifyContent: "space-between", padding: 72, background: "#06070A", color: "#F4F5F7", fontFamily: "sans-serif", position: "relative" }}>63        <div style={{ position: "absolute", top: -260, right: -180, width: 760, height: 760, borderRadius: 760, background: `radial-gradient(closest-side, ${accent}66, transparent)`, display: "flex" }} />64        <div style={{ position: "absolute", top: -200, left: -240, width: 640, height: 640, borderRadius: 640, background: "radial-gradient(closest-side, #4C8DFF44, transparent)", display: "flex" }} />65        <div style={{ display: "flex", alignItems: "center", gap: 18 }}>66          <svg width="46" height="46" viewBox="0 0 32 32" fill="none"><circle cx="16" cy="16" r="11" stroke="#8F6BFF" strokeWidth="3.4" /><circle cx="25.2" cy="6.8" r="3.4" fill="#F4F5F7" stroke="#06070A" strokeWidth="1.6" /></svg>67          <div style={{ fontSize: 34, fontWeight: 600, letterSpacing: 9 }}>ORIX</div>68        </div>69        <div style={{ display: "flex", alignItems: "flex-end", justifyContent: "space-between", gap: 48 }}>70          <div style={{ display: "flex", flexDirection: "column", maxWidth: icon ? 780 : 1000 }}>71            <div style={{ fontSize: 24, letterSpacing: 5, color: "#8A91A1", textTransform: "uppercase" }}>{o.kicker}</div>72            <div style={{ fontSize: o.title.length > 28 ? 68 : 88, fontWeight: 700, letterSpacing: -3, lineHeight: 1.02, marginTop: 18 }}>{o.title}</div>73            <div style={{ fontSize: 34, color: "#A9AFBC", marginTop: 22, lineHeight: 1.25 }}>{o.subtitle}</div>74          </div>75          {icon && <img src={icon} width={232} height={232} style={{ borderRadius: 52, boxShadow: `0 30px 80px ${accent}55` }} />}76        </div>77      </div>78    ),79    OG_SIZE,80  );81}82
Files main
Menu

Theme