---
import { ViewTransitions } from 'astro:transitions'
import '../styles/fonts.css'
import '../styles/global.css'

export interface Props {
  title: string
  description: string
  permalink: string
}

const { title, description, permalink } = Astro.props
const socialUrl = Astro.site.href + 'assets/social.png'
---

<!-- Global Metadata -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />

<!-- Primary Meta Tags -->
<title>{title}</title>
<meta name="title" content={title} />
<meta name="description" content={description} />

<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta property="og:url" content={permalink} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={socialUrl} />

<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content={permalink} />
<meta property="twitter:title" content={title} />
<meta property="twitter:description" content={description} />
<meta property="twitter:image" content={socialUrl} />

<ViewTransitions />

<!-- This is intentionally inlined to avoid FOUC -->
<script is:inline>
  const root = document.documentElement
  const theme = localStorage.getItem('theme')
  if (
    theme === 'dark' ||
    (!theme && window.matchMedia('(prefers-color-scheme: dark)').matches)
  ) {
    root.classList.add('theme-dark')
  } else {
    root.classList.remove('theme-dark')
  }
</script>
