---
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/yht_logo.png'
---

<!-- Global Metadata -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/x-icon" href="/favicon.png" />
<link
    rel="alternate"
    type="application/rss+xml"
    title="YouHaveBlog RSS Feed"
    href={new URL("rss.xml", Astro.site)}
/>

<link rel="preload" href="/assets/fonts/va9B4kDNxMZdWfMOD5VnLK3eRhf6Xl7Glw.woff2" as="font" crossorigin="anonymous" />
<link rel="preload" href="/assets/fonts/u-440qyriQwlOrhSvowK_l5-fCZMdeX3rg.woff2" as="font" crossorigin="anonymous" />
<link rel="preload" href="/assets/fonts/u-4n0qyriQwlOrhSvowK_l52xwNZWMf6hPvhPQ.woff2" as="font" crossorigin="anonymous"/>

<!-- Primary Meta Tags -->
<title> {title} | YouHaveTrouble's place</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} />

<!-- 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>
