Files
v10/website/src/layouts/Base.astro
T
2025-10-21 08:56:42 -07:00

90 lines
2.9 KiB
Plaintext

---
import type { ImageMetadata } from 'astro';
import { Font } from 'astro:assets';
import { SITE_TITLE } from '@/consts';
import '@/styles/globals.css';
import FooterEasterEgg from '@/components/FooterEasterEgg.astro';
import Posthog from '@/components/Posthog.astro';
interface Props {
title: string | string[];
description: string;
image?: ImageMetadata;
}
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
const { title, description, image } = Astro.props;
const fullTitle = Array.isArray(title)
? title.filter((t) => t !== SITE_TITLE).join(' | ') + ` | ${SITE_TITLE}`
: title === SITE_TITLE
? title
: `${title} | ${SITE_TITLE}`;
---
<html lang="en">
<head>
{/* Global Metadata */}
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="icon" href="/favicon.ico" sizes="32x32" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="sitemap" href="/sitemap-index.xml" />
<link rel="alternate" type="application/rss+xml" title={SITE_TITLE} href={new URL('rss.xml', Astro.site)} />
<meta name="generator" content={Astro.generator} />
{/* Important stuff */}
<slot name="priority-head" />
{/* Font preloads */}
<Font cssVariable="--font-instrument-sans" preload />
<Font cssVariable="--font-ibm-plex-mono" preload />
{/* Canonical URL */}
<link rel="canonical" href={canonicalURL} />
{/* Primary Meta Tags */}
<title>{fullTitle}</title>
<meta name="title" content={fullTitle} />
<meta name="description" content={description} />
{/* Open Graph / Facebook */}
<meta property="og:type" content="website" />
<meta property="og:url" content={Astro.url} />
<meta property="og:title" content={fullTitle} />
<meta property="og:description" content={description} />
{image && <meta property="og:image" content={new URL(image.src, Astro.url)} />}
{/* Twitter */}
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content={Astro.url} />
<meta property="twitter:title" content={fullTitle} />
<meta property="twitter:description" content={description} />
{image && <meta property="twitter:image" content={new URL(image.src, Astro.url)} />}
{/* Whatever else */}
<slot name="head" />
{/* Analytics */}
<Posthog />
</head>
<body
class:list={[
'relative',
'bg-light-80 text-dark-100',
'font-sans antialiased text-pretty text-base',
'min-w-80',
'[--nav-h:calc(var(--spacing)*13)] lg:[--nav-h:calc(var(--spacing)*14)]',
'selection:bg-yellow selection:text-dark-100',
]}
>
{/* BaseUI requires body.relative and div.isolate */}
<div class="isolate">
<slot />
<FooterEasterEgg />
</div>
</body>
</html>