---
import type { Site } from '../content/schemas';

interface Props {
  title?: string;
  description?: string;
  site: Site;
}

const { title, description, site } = Astro.props;
const pageTitle = title ? `${title} — ${site.title}` : site.title;
const pageDescription = description ?? site.description;
const canonical = new URL(Astro.url.pathname, site.url).toString();
const ogImage = new URL(site.ogImage, site.url).toString();
---

<title>{pageTitle}</title>
<meta name="description" content={pageDescription} />
<meta name="keywords" content={site.keywords.join(', ')} />
<link rel="canonical" href={canonical} />

<meta property="og:type" content="website" />
<meta property="og:title" content={pageTitle} />
<meta property="og:description" content={pageDescription} />
<meta property="og:url" content={canonical} />
<meta property="og:image" content={ogImage} />

<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={pageTitle} />
<meta name="twitter:description" content={pageDescription} />
<meta name="twitter:image" content={ogImage} />
