Skip to content

fix(metadata): parse a string updated_at from frontmatter - #225

Merged
eelcoj merged 1 commit into
Rails-Designer:mainfrom
pcbeingused333:fix/updated-at-string-frontmatter
Nov 23, 2026
Merged

eelcoj merged 1 commit into
Rails-Designer:mainfrom
pcbeingused333:fix/updated-at-string-frontmatter

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

A quoted updated_at in frontmatter breaks the sitemap and feeds.

Cause: updated_at is passed through from frontmatter untouched. When it is quoted (updated_at: "2023-05-15") YAML gives a String, so the sitemap (resource.metadata.updated_at&.iso8601, modification_dates.max) and the feeds (sort_by { published_at || metadata.updated_at || Time.current }) fail: String#iso8601 is undefined and comparing a String with Date/Time raises ArgumentError.

Fix: Metadata now parses a String updated_at with Time.zone.parse (the same approach publication_date uses for published_at), and drops it when it cannot be parsed. Unquoted dates are unchanged.

Test: two cases in metadata_test.rb (quoted date becomes a Time; garbage value becomes nil). Both fail before the change; the full suite passes (447 runs).

This PR was prepared with the assistance of an AI coding agent (Claude) and submitted by the account owner.

A quoted updated_at (updated_at: "2023-05-15") reached the sitemap and feeds as a String, so String#iso8601 was undefined and sorting/max against Date or Time raised. Parse it with Time.zone.parse like published_at, and drop it when unparseable.
@eelcoj
eelcoj merged commit 46f3847 into Rails-Designer:main Nov 23, 2026
3 checks passed
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