From 4f131eba43a76abed318dcd0abc5a285c30a7b21 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Fri, 10 Jul 2026 19:11:19 -0500 Subject: [PATCH] feat(blog): content collection, index, post layout, RSS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds the blog system ahead of the launch post: a zod-typed `blog` content collection (content layer glob loader), a card-list index with a calm empty state, the post route/layout with reading time, and an RSS feed — all wired to the existing Base shell and palette. Signed-off-by: Diego Resendez --- .superpowers/sdd/progress.md | 9 ++++ src/content.config.ts | 18 +++++++ src/content/blog/.gitkeep | 0 src/layouts/Post.astro | 99 ++++++++++++++++++++++++++++++++++ src/pages/blog/[...slug].astro | 29 ++++++++++ src/pages/blog/index.astro | 99 ++++++++++++++++++++++++++++++++++ src/pages/rss.xml.js | 19 +++++++ 7 files changed, 273 insertions(+) create mode 100644 src/content.config.ts create mode 100644 src/content/blog/.gitkeep create mode 100644 src/layouts/Post.astro create mode 100644 src/pages/blog/[...slug].astro create mode 100644 src/pages/blog/index.astro create mode 100644 src/pages/rss.xml.js diff --git a/.superpowers/sdd/progress.md b/.superpowers/sdd/progress.md index 75fba27..f9f2f5a 100644 --- a/.superpowers/sdd/progress.md +++ b/.superpowers/sdd/progress.md @@ -13,3 +13,12 @@ Task 1: complete (commit 0969882, review clean — spec PASS) Task 2: complete (landing page, spec PASS) 7 sections in src/components/sections/ (Hero, GraphNotChain, RunsEverywhere, RealTime, Batteries, SeeIt, HonestBeta), composed in index.astro. Verbatim copy per brief. Shared .kicker/.btn/.btn-row primitives added to global.css for reuse across sections. Hero: wordmark lockup + H1 + subhead + 3 CTAs + GraphMotif ambient (right side desktop, shrunk+faded below content on mobile). GraphNotChain: faint full-bleed GraphMotif behind text (opacity .14) + violet-bordered punch line. SeeIt: astro:components Code with theme="github-dark", exact snippet from brief. All CTAs use @green-tea/core (npm) and expressive-tea/green-tea (GitHub) placeholders per instruction, not Header's existing @expressive-tea/core. Build clean; 390px and 1440px verified zero horizontal overflow (scrollWidth === clientWidth) via headless Playwright; screenshots via astro preview over HTTP (not file://) per Task 1 carry-forward. CARRY-FORWARD: Header/Footer still reference @expressive-tea/core npm placeholder (Task 1 artifact, out of scope here) — inconsistent with @green-tea/core now used on the landing page; worth reconciling in a later task. + +Task 2: complete (commit 479a301, review clean — spec PASS) + Landing: 7 secciones (Hero, GraphNotChain con pull-quote violeta, RunsEverywhere chips, RealTime, Batteries 6-card, SeeIt Shiki code, HonestBeta + Thats the tea). Copy verbatim, 1 h1, a11y limpia, contraste AA, --violet correcto, responsive sin overflow. Visualmente fuerte/on-brand (confirmado). + IMPORTANT for Task 5 polish: normalizar placeholders — Header/Footer usan @expressive-tea/core, resto usa @green-tea/core (el correcto). GitHub = github.com/expressive-tea/green-tea en todos (placeholder a decidir). Minors: target=_blank inconsistente en docs links; punch line bold via CSS no . + +Task 3: complete (blog system, spec PASS) + `src/content.config.ts` — content layer API (`glob` loader from `astro/loaders`, pattern `**/[^_]*.{md,mdx}` over `src/content/blog`), zod schema exactly per brief (title/description/pubDate coerce/updatedDate optional/author default 'Diego Reséndez'/tags optional/draft default false/heroImage optional). `Post.astro` extends Base: Zen Maru h1, meta row (date · author · reading time from raw body @200wpm) + optional tags row, `.prose` article, back-to-blog link above and below content. `/blog/index.astro`: getCollection filtered non-draft, sorted pubDate desc, card list; renders calm "No posts yet." when empty — verified via screenshot over `astro preview` HTTP. `/blog/[...slug].astro`: getStaticPaths + `render()` from `astro:content`. `rss.xml.js`: `@astrojs/rss`, title "Green Tea — Blog", non-draft items; Base.astro already had the `` from Task 1. `src/content/blog/.gitkeep` keeps the empty dir tracked (real post lands Task 4). + Verification: built + previewed with a throwaway temp post (not committed) to prove the post route/layout/RSS item render correctly, then removed it and did a clean `rm -rf dist .astro` + rebuild to confirm the true empty-collection state (`getCollection` returns `[]`, `/blog` shows empty-state, `rss.xml` has zero ``s) — `npm run build` succeeds either way; astro logs a benign glob-loader/"collection does not exist" WARN on zero files, not a build error. + CARRY-FORWARD: none new. Task 5 polish note from Task 2 (placeholder normalization) still open. diff --git a/src/content.config.ts b/src/content.config.ts new file mode 100644 index 0000000..92e102a --- /dev/null +++ b/src/content.config.ts @@ -0,0 +1,18 @@ +import { defineCollection, z } from 'astro:content'; +import { glob } from 'astro/loaders'; + +const blog = defineCollection({ + loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: './src/content/blog' }), + schema: z.object({ + title: z.string(), + description: z.string(), + pubDate: z.coerce.date(), + updatedDate: z.coerce.date().optional(), + author: z.string().default('Diego Reséndez'), + tags: z.array(z.string()).optional(), + draft: z.boolean().default(false), + heroImage: z.string().optional(), + }), +}); + +export const collections = { blog }; diff --git a/src/content/blog/.gitkeep b/src/content/blog/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/layouts/Post.astro b/src/layouts/Post.astro new file mode 100644 index 0000000..4109075 --- /dev/null +++ b/src/layouts/Post.astro @@ -0,0 +1,99 @@ +--- +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' }); + +const wordCount = body.trim().split(/\s+/).filter(Boolean).length; +const readingTime = Math.max(1, Math.round(wordCount / 200)); +--- + + +
+
+

← Back to the blog

+

{title}

+ + {tags && tags.length > 0 && ( + + )} +
+ +
+

← Back to the blog

+
+
+ + + diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro new file mode 100644 index 0000000..82976fb --- /dev/null +++ b/src/pages/blog/[...slug].astro @@ -0,0 +1,29 @@ +--- +import { getCollection, render } from 'astro:content'; +import Post from '../../layouts/Post.astro'; + +export async function getStaticPaths() { + const posts = await getCollection('blog', ({ data }) => !data.draft); + + return posts.map((post) => ({ + params: { slug: post.id }, + props: { post }, + })); +} + +const { post } = Astro.props; +const { Content } = await render(post); +--- + + + + diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro new file mode 100644 index 0000000..ba9d0ca --- /dev/null +++ b/src/pages/blog/index.astro @@ -0,0 +1,99 @@ +--- +import { getCollection } from 'astro:content'; +import Base from '../../layouts/Base.astro'; + +const title = 'Blog — Green Tea.'; +const description = 'Notes on building a zen, opinionated, type-safe HTTP framework.'; + +const posts = (await getCollection('blog', ({ data }) => !data.draft)).sort( + (a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf() +); + +const dateFormat = new Intl.DateTimeFormat('en-US', { month: 'long', day: 'numeric', year: 'numeric' }); +--- + + +
+
+

Blog

+

From the garden

+ + { + posts.length === 0 ? ( +

No posts yet.

+ ) : ( +
    + {posts.map((post) => ( +
  • +

    + {post.data.title} +

    +

    + +

    +

    {post.data.description}

    + {post.data.tags && post.data.tags.length > 0 && ( +

    + {post.data.tags.map((tag) => ( + {tag} + ))} +

    + )} +
  • + ))} +
+ ) + } +
+
+ + + diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js new file mode 100644 index 0000000..2fd8bc8 --- /dev/null +++ b/src/pages/rss.xml.js @@ -0,0 +1,19 @@ +import rss from '@astrojs/rss'; +import { getCollection } from 'astro:content'; + +export async function GET(context) { + const posts = await getCollection('blog', ({ data }) => !data.draft); + const sorted = posts.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()); + + return rss({ + title: 'Green Tea — Blog', + description: 'Notes on building a zen, opinionated, type-safe HTTP framework.', + site: context.site, + items: sorted.map((post) => ({ + title: post.data.title, + description: post.data.description, + pubDate: post.data.pubDate, + link: `/blog/${post.id}/`, + })), + }); +}