Skip to content

refactor(posts): map frontmatter DTOs and share the date formatter - #32

Merged
helderberto merged 2 commits into
mainfrom
refactor/structure-6-posts
Oct 24, 2026
Merged

helderberto merged 2 commits into
mainfrom
refactor/structure-6-posts

Conversation

@helderberto

Copy link
Copy Markdown
Owner

Context

Part 6 of 7, based on part 5. Post frontmatter is external data and was read as any; two components formatted dates separately.

Summary

  • parseMarkdown<T>() in lib/gray-matter is the one place the untyped frontmatter gets a type.
  • PostFrontmatterDto / PostFileDto in types/post.ts; toPostSummary and toPost in features/posts/post-mapper.ts map them to Post. Same fields, same order, same defaults.
  • features/posts/format-post-date.ts (short / long, always UTC) replaces the formatting in PostCard and PostHeader. It stays in the feature: only posts use it.

Evidence

  • Before: reading-time and default tests ran through fs mocks.
  • After: they run on the mapper directly, and posts.test.ts keeps the file-reading integration. Changing words per minute, the tags default or the lastModified fallback each fails a test. The formatter is tested in America/Sao_Paulo, and dropping timeZone: 'UTC' fails it.

Merge danger

Door: two-way

Blast radius: posts


Generated by Claude Code

@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
website Ready Ready Preview Oct 24, 2026 10:56am UTC

@helderberto
helderberto force-pushed the refactor/structure-5-lint branch from 4b8afb3 to e504986 Compare October 24, 2026 10:55
Base automatically changed from refactor/structure-5-lint to main October 24, 2026 10:55
Post frontmatter is external data: type it as PostFrontmatterDto at the
parse boundary (parseMarkdown in the gray-matter wrapper) and turn it
into a Post with toPostSummary and toPost. Output is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DZqAJbwwPeQSQFaPLDDSfr
PostCard and PostHeader each formatted the frontmatter date in UTC;
both now call formatPostDate with a short or long style.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DZqAJbwwPeQSQFaPLDDSfr
@helderberto
helderberto force-pushed the refactor/structure-6-posts branch from c225430 to d41fec6 Compare October 24, 2026 10:55
@helderberto
helderberto merged commit cb7d9c1 into main Oct 24, 2026
1 check was pending
@helderberto
helderberto deleted the refactor/structure-6-posts branch October 24, 2026 10:55

This branch was successfully deployed

1 active deployment
Preview — d41fec63 Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants