import type { Metadata } from "next";
import "./globals.css";
import Header from "@/components/Header";
import Footer from "@/components/Footer";
import { getBreakingPosts } from "@/lib/wordpress";
import BreakingTicker from "@/components/BreakingTicker";

export const metadata: Metadata = {
  title:       { default: "MegaBlog — Global News", template: "%s | MegaBlog" },
  description: "Breaking news, sports, entertainment, technology and politics from every continent.",
  openGraph: {
    type:    "website",
    locale:  "en_US",
    siteName:"MegaBlog",
  },
};

export default async function RootLayout({ children }: { children: React.ReactNode }) {
  const breakingPosts = await getBreakingPosts().catch(() => []);

  return (
    <html lang="en">
      <body className="min-h-screen bg-[#0a0a0a] text-white">
        <Header />
        <BreakingTicker posts={breakingPosts} />
        <main className="min-h-screen">{children}</main>
        <Footer />
      </body>
    </html>
  );
}
