Files
v10/site/src/layouts/Base.astro
T

111 lines
4.0 KiB
Plaintext

---
import { Font } from 'astro:assets';
import type { ImageMetadata } from 'astro';
import { SEO_SUFFIX, SITE_TITLE } from '@/consts';
import '@/styles/globals.css';
import { PreferenceSync } from '@/components/docs/PreferenceSync';
import FilmGrain from '@/components/FilmGrain';
import ThemeInit from '@/components/ThemeInit.astro';
interface Props {
title: string | string[];
description: string;
image?: ImageMetadata;
canonical?: string;
suffix?: string;
}
const { canonical, suffix } = Astro.props;
const canonicalURL = canonical || new URL(Astro.url.pathname, Astro.site);
const { title, description, image } = Astro.props;
const seoSuffix = suffix ?? SEO_SUFFIX;
const pageTitle = Array.isArray(title) ? title.join(' | ') : title;
const fullTitle =
pageTitle === SITE_TITLE ? `${SITE_TITLE} | ${seoSuffix}` : `${pageTitle} | ${SITE_TITLE} | ${seoSuffix}`;
---
<html lang="en">
<head>
{/* Global Metadata */}
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="theme-color" content="#ebe4c1" />
<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" />
{/* Preconnect to Mux for faster video/image loading */}
<link rel="preconnect" href="https://image.mux.com" crossorigin />
<link rel="preconnect" href="https://stream.mux.com" crossorigin />
{/* Font preloads */}
<Font cssVariable="--font-instrument-sans" preload />
<Font cssVariable="--font-ibm-plex-mono" preload />
<link rel="preload" href="https://static.mux.com/fonts/EurostileLTProBold/font.woff2" as="font" type="font/woff2" crossorigin />
<link rel="preload" href="https://static.mux.com/fonts/EurostileLTProExtended2/font.woff2" as="font" type="font/woff2" crossorigin />
<link rel="preload" href="https://static.mux.com/fonts/EurostileLTProBoldExtended2/font.woff2" as="font" type="font/woff2" crossorigin />
{/* 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" />
<ThemeInit />
</head>
<body
class:list={[
'relative',
'font-sans antialiased text-pretty text-base',
'bg-light-80 dark:bg-dark-100 text-dark-100 dark:text-light-100',
'min-w-80',
'[--nav-h:calc(var(--spacing)*13)] sm:[--nav-h:calc(var(--spacing)*14)]',
'selection:bg-yellow selection:text-dark-100',
]}
>
<div
class:list={[
// BaseUI requires body.relative and div.isolate
'isolate',
// background colors are applied here for a more consistent FilmGrain blending
'bg-light-80 dark:bg-dark-100',
]}
>
<PreferenceSync client:idle />
<FilmGrain currentPath={Astro.url.pathname} />
<slot />
</div>
</body>
</html>