]> git.maquefel.me Git - brevno-suite/hugo/commit
Fix it so YAML integer types can be used where Go int types are expected
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 22 Oct 2025 12:22:59 +0000 (14:22 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 22 Oct 2025 19:04:39 +0000 (21:04 +0200)
commitd4c78885ae4cb7c488ea2ed399aa57f0861f44cb
treec0a3f3c16ec3819643c726abdc571b690c0ef3a8
parent29e2c2fa92b10c1250376913558448e838e390fe
Fix it so YAML integer types can be used where Go int types are expected

E.g. in date.AddDate.

In Hugo v0.152.0 we moved to a new YAML library (github.com/goccy/go-yaml) which produces uint64 for unsigned integers.

This unfortunately breaks common constructs like:

  .Date.AddDate 0 0 7

when .Date is a time.Time and the integers are unmarshaled from YAML front matter.

This commit adds code to handle conversion from uint64 (and other int types) to the required int types where possible.

Fixes #14079
common/hreflect/helpers.go
common/hreflect/helpers_test.go
tpl/internal/go_templates/texttemplate/exec.go
tpl/internal/go_templates/texttemplate/hugo_template.go
tpl/templates/templates_integration_test.go