---
import "../styles/global.css";
import Header from "../components/Header.astro";
import Footer from "../components/Footer.astro";
import { site } from "../data/site";

interface Props {
  title?: string;
  description?: string;
  canonical?: string;
  noindex?: boolean;
}

const {
  title = site.name,
  description = site.description,
  canonical = Astro.url.pathname,
  noindex = false,
} = Astro.props;

const pageTitle = title === site.name ? title : `${title} | ${site.name}`;
const canonicalUrl = new URL(canonical, site.url).toString();
---

<!doctype html>
<html lang="de">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="generator" content={Astro.generator} />
    <title>{pageTitle}</title>
    <meta name="description" content={description} />
    <link rel="canonical" href={canonicalUrl} />
    {noindex && <meta name="robots" content="noindex, follow" />}
    <link rel="icon" href="/assets/img/logo-heidrich-square.png" />
    <meta property="og:title" content={pageTitle} />
    <meta property="og:description" content={description} />
    <meta property="og:type" content="website" />
    <meta property="og:url" content={canonicalUrl} />
    <meta property="og:image" content={new URL("/assets/img/firmengelaende-luftaufnahme.jpg", site.url).toString()} />
    <slot name="head" />
  </head>
  <body>
    <Header />
    <main id="main-content">
      <slot />
    </main>
    <Footer />
  </body>
</html>
