Files
website/src/layouts/Post.astro
T
chrnx c349dbd514 fix: post date off-by-one and inconsistent placeholder links
Post/blog-index dates formatted pubDate in the local timezone, so a
UTC-midnight date like 2026-07-10 rendered as July 9 anywhere west
of UTC. Format with timeZone: 'UTC' to match the stored date.

Also normalizes the npm package to @green-tea/core everywhere (Header
and Footer still pointed at @expressive-tea/core) and settles on a
single GitHub placeholder (https://github.com/green-tea-dev/green-tea)
across Header, Footer, Hero, and HonestBeta — documented in the README
as unconfirmed until launch. Docs CTAs in Hero and HonestBeta now open
in a new tab with rel="noopener noreferrer", matching Header/Footer.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 19:21:26 -05:00

105 lines
2.2 KiB
Plaintext

---
import Base from './Base.astro';
interface Props {
title: string;
description: string;
pubDate: Date;
updatedDate?: Date;
author: string;
tags?: string[];
heroImage?: string;
body: string;
}
const { title, description, pubDate, updatedDate, author, tags, heroImage, body } = Astro.props;
const dateFormat = new Intl.DateTimeFormat('en-US', {
month: 'long',
day: 'numeric',
year: 'numeric',
timeZone: 'UTC',
});
const wordCount = body.trim().split(/\s+/).filter(Boolean).length;
const readingTime = Math.max(1, Math.round(wordCount / 200));
---
<Base title={`${title} — Green Tea. Blog`} description={description} image={heroImage}>
<article class="post section">
<div class="wrap prose">
<p class="post-nav"><a href="/blog/">← Back to the blog</a></p>
<h1>{title}</h1>
<p class="post-meta">
<time datetime={pubDate.toISOString()}>{dateFormat.format(pubDate)}</time>
<span aria-hidden="true"> · </span>
{author}
<span aria-hidden="true"> · </span>
{readingTime} min read
{
updatedDate && (
<>
<span aria-hidden="true"> · </span>
<span>Updated {dateFormat.format(updatedDate)}</span>
</>
)
}
</p>
{tags && tags.length > 0 && (
<p class="post-tags">
{tags.map((tag) => <span class="tag">{tag}</span>)}
</p>
)}
<div class="post-body">
<slot />
</div>
<p class="post-back"><a href="/blog/">← Back to the blog</a></p>
</div>
</article>
</Base>
<style>
.post-nav {
font-size: 0.9rem;
margin: 0 0 1.5em;
}
.post-nav a {
color: var(--dim);
}
.post-nav a:hover,
.post-nav a:focus-visible {
color: var(--matcha);
}
.post-meta {
color: var(--dim);
font-size: 0.95rem;
margin: 0 0 1.5em;
}
.post-tags {
display: flex;
flex-wrap: wrap;
gap: 0.5em;
margin: 0 0 1.5em;
}
.tag {
display: inline-block;
font-size: 0.75rem;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--matcha);
background: var(--panel);
border-radius: 6px;
padding: 0.25em 0.6em;
}
.post-back {
margin-top: 3em;
}
</style>