Files
hype404-static/src/layouts/Layout.astro

482 lines
13 KiB
Plaintext
Raw Normal View History

---
import { site } from '../lib/site.js';
const {
title,
description = site.description,
canonical,
image,
structuredData,
} = Astro.props;
const pageTitle = title || site.name;
const ogUrl = canonical || Astro.url.toString();
const year = new Date().getFullYear();
---
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{pageTitle}</title>
<meta name="description" content={description} />
{canonical && <link rel="canonical" href={canonical} />}
<link rel="icon" href="/favicon.ico" sizes="any" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="apple-touch-icon" href="/favicon-32x32.png" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content={site.name} />
<meta property="og:title" content={pageTitle} />
<meta property="og:description" content={description} />
{image && <meta property="og:image" content={image} />}
<meta property="og:url" content={ogUrl} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={pageTitle} />
<meta name="twitter:description" content={description} />
{image && <meta name="twitter:image" content={image} />}
{structuredData && (
<script type="application/ld+json" set:html={structuredData} />
)}
<link rel="alternate" type="application/rss+xml" title={`${site.name} RSS`} href="/rss.xml" />
<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=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700;9..144,800&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
<style is:global>
:root {
--bg: #fbfaf6;
--bg-card: #ffffff;
--bg-soft: #f4f1ea;
--ink: #16161a;
--ink-soft: #4b4b52;
--ink-muted: #84848d;
--line: #e7e3d6;
--accent: #e85d3c;
--accent-soft: #fbe4dc;
--link: #1f4ddb;
--link-hover: #102a8c;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html {
background: var(--bg);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-rendering: optimizeLegibility;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
font-size: 17px;
line-height: 1.65;
color: var(--ink);
background: var(--bg);
min-height: 100vh;
}
.container {
max-width: 1100px;
margin: 0 auto;
padding: 0 28px;
}
/* ========== Site header ========== */
header.hero {
padding: 36px 0 28px;
border-bottom: 1px solid var(--line);
margin-bottom: 48px;
}
.hero-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
flex-wrap: wrap;
}
.brand-link { text-decoration: none; color: inherit; display: inline-block; }
.ascii-brand {
font-family: 'Fraunces', 'Times New Roman', serif;
font-weight: 800;
font-size: 38px;
letter-spacing: -0.02em;
color: var(--ink);
line-height: 1;
font-variation-settings: 'opsz' 144;
}
.ascii-brand .cursor {
color: var(--accent);
font-weight: 800;
}
.tagline {
color: var(--ink-soft);
font-family: 'Fraunces', serif;
font-style: italic;
font-size: 16px;
margin-top: 6px;
max-width: 520px;
font-variation-settings: 'opsz' 14;
}
nav.nav {
display: flex;
gap: 24px;
font-size: 14px;
font-weight: 500;
}
nav.nav a {
color: var(--ink-soft);
text-decoration: none;
letter-spacing: 0.02em;
transition: color 0.15s;
}
nav.nav a:hover { color: var(--accent); }
main { padding: 0 0 64px; }
/* ========== Index post cards ========== */
.post {
background: var(--bg-card);
border: 1px solid var(--line);
border-radius: 12px;
padding: 28px 32px;
margin-bottom: 18px;
transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.post:hover {
transform: translateY(-2px);
box-shadow: 0 12px 32px -16px rgba(20, 20, 30, 0.18);
border-color: #d8d2c0;
}
.post-title {
font-family: 'Fraunces', serif;
font-weight: 600;
font-size: 26px;
line-height: 1.2;
letter-spacing: -0.015em;
margin-bottom: 8px;
font-variation-settings: 'opsz' 80;
}
.post-title a {
color: var(--ink);
text-decoration: none;
}
.post-title a:hover { color: var(--accent); }
.post-meta {
color: var(--ink-muted);
font-size: 13px;
letter-spacing: 0.02em;
margin-bottom: 12px;
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
.post-excerpt {
color: var(--ink-soft);
font-size: 16px;
line-height: 1.6;
}
/* ========== Tags ========== */
.tag {
display: inline-block;
background: var(--bg-soft);
color: var(--ink-soft);
padding: 2px 10px;
border-radius: 999px;
border: 1px solid var(--line);
font-size: 12px;
font-weight: 500;
letter-spacing: 0.02em;
transition: background 0.15s, color 0.15s;
}
.tag a { color: inherit; text-decoration: none; }
.tag:hover { background: var(--accent-soft); color: var(--accent); }
/* ========== Article (post detail) ========== */
.post-content {
max-width: 720px;
margin: 0 auto;
padding: 0;
background: transparent;
border: none;
font-size: 18px;
line-height: 1.75;
color: var(--ink);
}
.post-content h1 {
font-family: 'Fraunces', serif;
font-weight: 700;
font-size: clamp(32px, 5vw, 48px);
line-height: 1.1;
letter-spacing: -0.02em;
color: var(--ink);
margin-bottom: 18px;
font-variation-settings: 'opsz' 144;
}
.post-content h2 {
font-family: 'Fraunces', serif;
font-weight: 600;
font-size: 28px;
line-height: 1.25;
letter-spacing: -0.015em;
color: var(--ink);
margin: 44px 0 14px;
font-variation-settings: 'opsz' 80;
}
.post-content h3 {
font-family: 'Fraunces', serif;
font-weight: 600;
font-size: 22px;
line-height: 1.3;
color: var(--ink);
margin: 32px 0 10px;
font-variation-settings: 'opsz' 36;
}
.post-content p {
margin-bottom: 22px;
color: var(--ink);
}
.post-content > p:first-of-type::first-letter {
font-family: 'Fraunces', serif;
font-weight: 700;
font-size: 64px;
float: left;
line-height: 0.92;
padding: 6px 10px 0 0;
color: var(--accent);
font-variation-settings: 'opsz' 144;
}
.post-content a {
color: var(--link);
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 3px;
transition: color 0.15s;
}
.post-content a:hover { color: var(--link-hover); }
.post-content img {
max-width: 100%;
height: auto;
border-radius: 10px;
margin: 28px 0;
box-shadow: 0 12px 36px -18px rgba(20, 20, 30, 0.25);
}
.post-content blockquote {
border-left: 3px solid var(--accent);
margin: 28px 0;
padding: 4px 0 4px 24px;
font-family: 'Fraunces', serif;
font-style: italic;
font-size: 21px;
line-height: 1.5;
color: var(--ink-soft);
font-variation-settings: 'opsz' 36;
}
.post-content code {
background: var(--bg-soft);
color: var(--accent);
padding: 1px 7px;
border-radius: 4px;
font-family: 'JetBrains Mono', 'SF Mono', monospace;
font-size: 0.88em;
}
.post-content pre {
background: #1a1a1f;
color: #e8e6df;
padding: 18px 20px;
border-radius: 10px;
overflow-x: auto;
margin: 24px 0;
font-family: 'JetBrains Mono', 'SF Mono', monospace;
font-size: 14px;
line-height: 1.65;
}
.post-content pre code {
background: transparent;
color: inherit;
padding: 0;
}
.post-content ul, .post-content ol {
margin: 18px 0 22px 28px;
}
.post-content li { margin-bottom: 8px; }
.post-content hr {
border: none;
border-top: 1px solid var(--line);
margin: 40px 0;
}
.back-link {
display: inline-block;
color: var(--ink-muted);
text-decoration: none;
margin-bottom: 24px;
font-size: 14px;
font-weight: 500;
letter-spacing: 0.02em;
transition: color 0.15s;
}
.back-link:hover { color: var(--accent); }
/* ========== Pagination ========== */
.pagination {
max-width: 720px;
margin: 48px auto 0;
padding-top: 24px;
border-top: 1px solid var(--line);
display: flex;
justify-content: space-between;
align-items: center;
gap: 16px;
}
.pagination-link {
display: inline-block;
padding: 8px 18px;
background: var(--bg-card);
border: 1px solid var(--line);
border-radius: 999px;
color: var(--ink);
text-decoration: none;
font-size: 14px;
font-weight: 500;
transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pagination-link:hover {
background: var(--accent);
border-color: var(--accent);
color: #fff;
}
.pagination-info {
color: var(--ink-muted);
font-size: 13px;
}
/* ========== Related posts ========== */
.related-posts {
max-width: 1100px;
margin: 64px auto 0;
padding-top: 36px;
border-top: 1px solid var(--line);
}
.related-posts h3 {
font-family: 'Fraunces', serif;
font-weight: 600;
font-size: 22px;
letter-spacing: -0.01em;
color: var(--ink);
margin-bottom: 22px;
font-variation-settings: 'opsz' 36;
}
.related-posts-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
gap: 16px;
}
.related-post-card {
background: var(--bg-card);
border: 1px solid var(--line);
border-radius: 10px;
padding: 20px;
transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.related-post-card:hover {
transform: translateY(-2px);
box-shadow: 0 10px 28px -16px rgba(20, 20, 30, 0.18);
border-color: #d8d2c0;
}
.related-post-link { text-decoration: none; color: inherit; display: block; }
.related-post-link h4 {
font-family: 'Fraunces', serif;
font-weight: 600;
font-size: 18px;
line-height: 1.25;
color: var(--ink);
margin-bottom: 8px;
font-variation-settings: 'opsz' 36;
}
.related-post-excerpt {
color: var(--ink-soft);
font-size: 14px;
line-height: 1.55;
margin-bottom: 10px;
}
.related-post-date {
color: var(--ink-muted);
font-size: 12px;
letter-spacing: 0.02em;
}
/* ========== Footer ========== */
footer {
max-width: 1100px;
margin: 80px auto 0;
padding: 28px 28px 36px;
border-top: 1px solid var(--line);
color: var(--ink-muted);
font-size: 13px;
display: flex;
justify-content: space-between;
align-items: center;
gap: 16px;
flex-wrap: wrap;
}
footer .footer-brand {
font-family: 'Fraunces', serif;
font-weight: 600;
color: var(--ink-soft);
letter-spacing: -0.01em;
}
footer .footer-brand .accent { color: var(--accent); }
/* ========== Mobile ========== */
@media (max-width: 700px) {
.container { padding: 0 18px; }
header.hero { padding: 24px 0 20px; margin-bottom: 32px; }
.ascii-brand { font-size: 30px; }
.tagline { font-size: 14px; }
.post { padding: 22px 22px; }
.post-title { font-size: 22px; }
.post-excerpt { font-size: 15px; }
.post-content { font-size: 17px; }
.post-content > p:first-of-type::first-letter { font-size: 52px; }
.related-posts-grid { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<div class="container">
<header class="hero">
<div class="hero-row">
<div>
<a href="/" class="brand-link">
<span class="ascii-brand">hype<span class="cursor">404</span></span>
</a>
<div class="tagline">{site.description}</div>
</div>
<nav class="nav">
<a href="/">Home</a>
<a href="/about/">About</a>
<a href="/rss.xml">RSS</a>
</nav>
</div>
</header>
<main>
<slot />
</main>
<footer>
<div class="footer-brand">hype<span class="accent">404</span></div>
<div>© {year} {site.name}</div>
</footer>
</div>
</body>
</html>