import React from "react";
import { Metadata } from "next";
import { notFound } from "next/navigation";
import HomeContent from "@/components/HomeContent";

export const metadata: Metadata = {
  title: "MB Grid Solutions | Energiekabelprojekte & Technische Beratung",
  description:
    "Ihr spezialisierter Partner für herstellerneutrale technische Beratung und Projektbegleitung bei Energiekabelprojekten bis 110 kV.",
};

interface PageProps {
  params: Promise<{ locale: string }>;
}

export default async function Page({ params }: PageProps) {
  const { locale } = await params;

  // Dynamically import the MDX content based on locale
  let Content: React.ComponentType;
  try {
    const mdx = await import(`@/content/${locale}/index.mdx`);
    Content = mdx.default;
  } catch (e) {
    // Fallback if MDX is not yet created for this locale
    return <HomeContent />;
  }

  // Render the MDX content.
  // We can use mdx-components.tsx to map MDX tags to our high-fidelity sections.
  return <Content />;
}
