Strengthen reusable Astro site foundation

This commit is contained in:
Kevin
2026-09-02 01:47:27 -04:00
parent 7557fa47b9
commit 19bba4282e
13 changed files with 101 additions and 16 deletions
+8 -1
View File
@@ -2,9 +2,11 @@
import '../styles/global.css';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import { deployment, isProduction, site } from '../lib/site-data.js';
import { deployment, isBlog, isProduction, site } from '../lib/site-data.js';
const { title = site.name, description = site.description } = Astro.props;
const canonical = `https://${deployment.hostname}${Astro.url.pathname}`;
const socialImage = new URL(site.seo.socialImage, `https://${deployment.hostname}`).href;
const structuredData = isBlog ? { '@context': 'https://schema.org', '@type': 'WebSite', name: site.name, url: `https://${deployment.hostname}` } : { '@context': 'https://schema.org', '@type': 'LocalBusiness', name: site.name, url: `https://${deployment.hostname}`, email: site.contact.email, telephone: site.contact.phoneHref, address: { '@type': 'PostalAddress', streetAddress: site.contact.address, addressLocality: site.seo.locality } };
---
<!doctype html>
<html lang="en">
@@ -17,12 +19,17 @@ const canonical = `https://${deployment.hostname}${Astro.url.pathname}`;
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:type" content="website" />
<meta property="og:url" content={canonical} />
<meta property="og:image" content={socialImage} />
<meta name="twitter:card" content="summary_large_image" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<title>{title}</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Serif+Display:ital@0;1&display=swap" rel="stylesheet" />
{isProduction && site.analyticsId && <script async src={`https://www.googletagmanager.com/gtag/js?id=${site.analyticsId}`}></script>}
{isProduction && site.analyticsId && <script define:vars={{ analyticsId: site.analyticsId }}>window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', analyticsId);</script>}
<script type="application/ld+json" set:html={JSON.stringify(structuredData)} />
</head>
<body style={`--accent:${site.theme.accent};--ink:${site.theme.ink};--surface:${site.theme.surface}`}>
<Header />