/** @type {import('next').NextConfig} */

// Allow next/image to load Ghost feature images from the configured CMS host.
const ghostHost = (() => {
  try {
    return process.env.GHOST_URL ? new URL(process.env.GHOST_URL).hostname : null;
  } catch {
    return null;
  }
})();

const nextConfig = {
  images: {
    remotePatterns: [
      { protocol: "https", hostname: "images.unsplash.com" },
      ...(ghostHost ? [{ protocol: "https", hostname: ghostHost }] : []),
    ],
  },
};

export default nextConfig;
