Coerce YAML Date frontmatter to a date string - #21
Open
CharanMN7 wants to merge 1 commit into
Open
Conversation
An unquoted `date: 2026-01-25` in frontmatter is parsed by gray-matter (via js-yaml) as a native Date, not a string. The loader's bare `typeof === 'string'` check dropped that to '', so the post sorted last and rendered "Invalid Date" downstream — silently, with no build warning. Several live sites (ai-charan-dev and likely others) have this today since nothing in the blog guide says to quote the date. Fixes #20 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E4mKgFidjkjdxyCziBsNnJ
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #20
loadBlogPosts/loadBlogPost/loadChangelogEntriesparsed frontmatter dateswith
typeof data.date === 'string' ? data.date.slice(0, 10) : ''. Anunquoted
date: 2026-01-25is parsed by gray-matter (via js-yaml, per theYAML spec's
!!timestamptype) as a nativeDate, not a string — so thatcheck dropped the date to
''. Effects: the post sorts last, and anythingrendering the date shows "Invalid Date". No build warning, easy to ship
without noticing.
Fix
Added
toDateString()— accepts either a string (existing.slice(0, 10)behavior, unchanged) or a
Dateinstance (formats as UTCYYYY-MM-DD).Used in both
toBlogPost()andloadChangelogEntries().Testing
Added
packages/framework/src/content.test.ts— real MDX fixtures on disk(via
DOCS_CONTENT_ROOT), covering an unquoted date, a quoted date, sortorder between the two, a changelog entry, and the missing-date fallback.
npx vitest run(99/99 passing) andnpx tsc --noEmitboth clean.Not in scope here
This doesn't touch the blog guide's example frontmatter (still shows
date: 2026-09-05unquoted) — now harmless either way, so no doc changeneeded. Sites already on an affected published version (
ai-charan-devandlikely others) will pick up the fix on their next
@inkform/frameworkbump once this is released.
🤖 Generated with Claude Code
https://claude.ai/code/session_01E4mKgFidjkjdxyCziBsNnJ