import { readFile } from "fs/promises";
import { join } from "path";
import { createBlogOpenGraphImage } from "@blog/next-og";
import { blogConfig } from "@/lib/blog-config";

export const alt = "Blog post cover image";
export const size = { width: 1200, height: 630 };
export const contentType = "image/png";

export default createBlogOpenGraphImage({
  config: blogConfig,
  siteName: "Smart Knowledge Systems",
  fallbackImage: async (slug) => {
    try {
      const buf = await readFile(
        join(process.cwd(), "src/assets", `${slug}.jpg`)
      );
      return `data:image/jpeg;base64,${buf.toString("base64")}`;
    } catch {
      return undefined;
    }
  },
  styles: {
    gradientFallback: "linear-gradient(135deg, #4338ca 0%, #1e1b4b 100%)",
    accentColor: "#a5b4fc",
  },
});
