Skip to content

Computer use CLI for AI agents

2.1 KB
Raw Blame
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import { ImageResponse } from "next/og";

const [geistRegular, geistPixelSquare] = await Promise.all([
  readFile(
    join(process.cwd(), "app/[lang]/desktop/og/[...slug]/geist-sans-regular.ttf")
  ),
  readFile(
    join(process.cwd(), "app/[lang]/desktop/og/[...slug]/GeistPixel-Square.ttf")
  ),
]);

export function renderOgImage(title: string) {
  return new ImageResponse(
    <div
      style={{
        width: "100%",
        height: "100%",
        display: "flex",
        flexDirection: "column",
        backgroundColor: "black",
        padding: "60px 80px",
      }}
    >
      <div style={{ display: "flex", alignItems: "center", gap: "16px" }}>
        <svg width="36" height="36" viewBox="0 0 16 16" fill="white">
          <path fillRule="evenodd" clipRule="evenodd" d="M8 1L16 15H0L8 1Z" />
        </svg>
        <span
          style={{ fontSize: 36, color: "#666", fontFamily: "Geist", fontWeight: 400 }}
        >
          /
        </span>
        <span
          style={{
            fontSize: 36,
            fontFamily: "GeistPixelSquare",
            fontWeight: 400,
            color: "white",
          }}
        >
          agent-desktop
        </span>
      </div>
      <div
        style={{
          display: "flex",
          flex: 1,
          flexDirection: "column",
          alignItems: "center",
          justifyContent: "center",
        }}
      >
        {title.split("\n").map((line, index) => (
          <span
            key={index}
            style={{
              fontSize: 72,
              fontFamily: "Geist",
              fontWeight: 400,
              color: "white",
              letterSpacing: "-0.02em",
              textAlign: "center",
              lineHeight: 1.2,
            }}
          >
            {line}
          </span>
        ))}
      </div>
    </div>,
    {
      width: 1200,
      height: 630,
      fonts: [
        { name: "Geist", data: geistRegular, style: "normal", weight: 400 },
        { name: "GeistPixelSquare", data: geistPixelSquare, style: "normal", weight: 400 },
      ],
    }
  );
}