import { getImgproxyUrl } from "./imgproxy";

/**
 * Next.js Image Loader for imgproxy
 *
 * @param {Object} props - properties from Next.js Image component
 * @param {string} props.src - The source image URL
 * @param {number} props.width - The desired image width
 * @param {number} props.quality - The desired image quality (ignored for now as imgproxy handles it)
 */
export default function imgproxyLoader({
  src,
  width,
  quality,
}: {
  src: string;
  width: number;
  quality?: number;
}) {
  // We use the width provided by Next.js for responsive images
  // Height is set to 0 to maintain aspect ratio
  return getImgproxyUrl(src, {
    width,
    resizing_type: "fit",
  });
}
