Skip to content

Keep string-backed Astro date fields quoted in frontmatter - #36

Merged
hfellerhoff merged 2 commits into
mainfrom
fix-astro-date-frontmatter-encoding
Sep 11, 2026
Merged

hfellerhoff merged 2 commits into
mainfrom
fix-astro-date-frontmatter-encoding

Conversation

@hfellerhoff

Copy link
Copy Markdown
Contributor
  • Editing a date field backed by z.string().date() (or z.iso.date() / z.iso.datetime()) in an Astro collection wrote it as a plain YAML scalar, which Astro then parsed as a timestamp and rejected with Expected type "string", received "object".
  • Astro's generated schema emits real dates (z.date(), z.coerce.date()) as a bare date-time with no pattern, while string date schemas keep their ISO validation pattern. The converter now uses that to mark string-backed date fields as options.quoted.
  • All dateField call sites in the form editors and new-file flow go through a shared plainDateField helper, so only real date schemas are written unquoted.
  • Adds tests covering both generated shapes and updates the Astro typed-collections docs table.

Astro's generated JSON schema emits both z.date() and z.string().date()
as date-formatted strings, so Posto treated every date field as a real
date and wrote it as a plain YAML scalar. For z.string().date() schemas
that value then parses as a timestamp and fails validation.

Real dates only reach the schema through Astro's toJSONSchema override,
which emits a bare date-time with no pattern, while string schemas keep
their ISO validation pattern. Use that to mark string-backed date fields
as quoted, and route every dateField call site through a shared helper
that honors the marker.
@hfellerhoff
hfellerhoff merged commit 728ad2c into main Sep 11, 2026
3 of 4 checks passed
@hfellerhoff
hfellerhoff deployed to production-signing September 11, 2026 18:49 — with GitHub Actions Active
@hfellerhoff
hfellerhoff deployed to production-signing September 11, 2026 18:49 — with GitHub Actions Active
@hfellerhoff
hfellerhoff deployed to production-signing September 11, 2026 18:49 — with GitHub Actions Active
@hfellerhoff
hfellerhoff deployed to production-signing September 11, 2026 18:49 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
production-signing — a84a9148 Deployed Sep 11, 2026 by hfellerhoff via release (ubuntu-22.04) #32
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.

1 participant