---
import BaseHead from "../components/BaseHead.astro";
import "../styles/global.css";
import "@fontsource/poppins/100.css";
import "@fontsource/poppins/400.css";
import "@fontsource/poppins/500.css";
import "@fontsource/poppins/700.css";
import "@fontsource-variable/kameron";
import ShareSticky from "../components/ShareSticky.vue";
import { routeTranslations } from "../i18n";
const { title, description, image, url, date } = Astro.props;

const currentLocale = Astro.currentLocale ?? "es";
const direction = currentLocale === "he" ? "rtl" : "ltr";

const newsSegments = Object.values(routeTranslations.news);
const editorialSegments = Object.values(routeTranslations.editorial);
const contentSegments = [...newsSegments, ...editorialSegments];
const isNewsPage = contentSegments.some((segment) =>
  Astro.url.pathname.includes(`/${segment}/`)
);
---

<html lang={currentLocale} dir={direction} class="scroll-smooth">
  <BaseHead
    title={title}
    description={description}
    image={image}
    url={url}
    date={date}
  />
  <script>
    document.addEventListener("contextmenu", (event) => {
      const target = event.target as HTMLElement;
      if (target.tagName === "IMG") {
        event.preventDefault();
      }
    });
  </script>
  <body class="font-primary">
    {isNewsPage && <ShareSticky client:only url={Astro.url.href} />}
    <slot />
  </body>
</html>
