发布日期: 2025-01-16
版本号: v0.141.0

此次更新新增了模板错误处理通用机制try、图像滤镜images.Mask、生成二维码的images.QR函数,并为images.Text添加了控制水平对齐的alignx选项。注意事项包括调整了ToMath与try的错误处理方式、重构GetRemote的错误处理逻辑,以及渲染钩子模板仅回退至HTML格式。修复了路径文档、资源路径冲突、模板多延迟处理、TailwindCSS兼容性等十余项问题。改进涉及弃用Twitter短代码改用X短代码、优化资源创建方式、新增多项性能基准测试等。同步更新了多个依赖库版本,包括golang.org/x/net升级至0.34.0,并对文档和构建配置进行了调整。

更新内容 (中文)

本次更新新增了模板内错误处理的通用机制try、新增图像滤镜images.Mask、新增images.QR函数、在images.Text中新增控制水平对齐的alignx选项等多项功能。

注意事项

  • 调整ToMath与try的错误处理 (note) dde9d9d54 @bep #13239
  • resources: 使用try替换GetRemote中的错误处理 (note) 0918e087e @bep #13216
  • 对于渲染钩子,仅回退到HTML(或默认输出格式)模板 76993369a @bep #13242

问题修复

  • common/paths: 修复文档注释 8b5262691 @jdbaldry
  • commands: 修正注释拼写 60c24fc5e @bep
  • 修复分支资源与bundle路径重叠问题 c5a63a3b4 @bep #13228
  • templates: 修复同一模板中多个defer的处理 61d3d2012 @bep #13236
  • 修复TailwindCSS v4的NPX问题 cfa080181 @bep #13221
  • 修复404模板变更后的服务端刷新 d913f46a8 @bep #13209

功能优化

  • tpl/tplimpl: 简化部分测试断言 1fad3832a @bep
  • tpl/tplimpl: 弃用twitter短代码,改用x短代码 1191467c0 @jmooring #13214
  • commands: 提前初始化全局日志器 41137077b @bep #13265
  • commands: 在config命令中添加–printZero选项 5bb156457 @bep
  • tpl/collections: 对Where、Sort和Merge使用MapRange/SetIterKey/SetIterValue de7137cc3 @bep
  • tpl/collections: 添加WhereMap基准测试 956f915f7 @bep
  • tpl/collections: 添加SortMap基准测试 a2a4166f6 @bep
  • tpl/collections: 添加Merge基准测试 39f582f9f @bep
  • resources/images: 重构golden测试使其更贴近实现 2501de7aa @bep
  • resources/images: 添加mask测试用例 06cc8673f @bep #13244
  • resources/images: 实现images.Mask 71fae9918 @trickkiste #13244
  • tpl/tplimpl: 为图像渲染钩子的alt属性使用纯文本 8af04745f @jmooring
  • resources/images: 添加images.QR的golden测试 892b49110 @bep
  • tpl/images: 将images.QR的签名改为images.QR TEXT OPTIONS b13d0a68e @jmooring #13230
  • resources/images: 添加images.Text的golden测试 d9594a96f @bep
  • images.Text: 新增水平对齐选项"alignx" 4a5cc2dd2 @jlskuz #10849
  • images: 重构golden测试体系 9cad8d38c @bep
  • create: 在hugo new中支持–noBuildLock参数 2a7bb1c7c @bep
  • tpl/images: 将QR哈希值格式化为十六进制 5f2adad2c @bep
  • tpl/images: 添加images.QR函数 4ea94c451 @jmooring #13205
  • 新增try机制 5d2cbee98 @bep #9737
  • resources: 添加FromOpts以更高效创建资源 723e3f434 @bep
  • markup/highlight: 移除noHl选项 2db43f841 @jmooring #9885

依赖更新

  • deps: 升级github.com/gohugoio/hashstructure从0.1.0至0.3.0 a2edf04c2 @bep
  • build(deps): 升级golang.org/x/tools从0.28.0至0.29.0 f024a5050 @dependabot[bot]
  • build(deps): 升级golang.org/x/net从0.33.0至0.34.0 80704bc9a @dependabot[bot]
  • build(deps): 升级github.com/evanw/esbuild从0.24.0至0.24.2 b7b49fb0f @dependabot[bot]
  • build(deps): 升级github.com/alecthomas/chroma/v2从2.14.0至2.15.0 a83797673 @dependabot[bot]

文档更新

  • docs: 重新生成CLI文档 88ecc3b75 @bep
  • docs: 再次生成CLI文档 44628616a @bep

构建配置

  • snap: 始终打包最新稳定版Go 3682027a5 @jmooring

更新内容 (原始)

This release adds try, a new general mechanism for handling errors within templates, a new images.Mask image filter, a new images.QR function, a new alignx option to control horizontal alignment in images.Text, and more.

Note

  • Adjust error handling in ToMath vs try (note) dde9d9d54 @bep #13239
  • resources: Replace error handling in GetRemote with try (note) 0918e087e @bep #13216
  • For render hooks, only fallback to HTML (or the defaultOutputFormat) template 76993369a @bep #13242

Bug fixes

  • common/paths: Fix docstring 8b5262691 @jdbaldry
  • commands: Fix spelling in comment 60c24fc5e @bep
  • Fix branch resource overlapping bundle path c5a63a3b4 @bep #13228
  • templates: Fix handling of multiple defers in the same template 61d3d2012 @bep #13236
  • Fix NPX issue with TailwindCSS v4 cfa080181 @bep #13221
  • Fix server refresh on 404 template changes d913f46a8 @bep #13209

Improvements

  • tpl/tplimpl: Simplify some test assertions 1fad3832a @bep
  • tpl/tplimpl: Deprecate twitter shortcode in favor of x shortcode 1191467c0 @jmooring #13214
  • commands: Set up the glboal logger early 41137077b @bep #13265
  • commands: Add –printZero to the config command 5bb156457 @bep
  • tpl/collections: Use MapRange/SetIterKey/SetIterValue for Where, Sort and Merge de7137cc3 @bep
  • tpl/collections: Add BenchmarkWhereMap 956f915f7 @bep
  • tpl/collections: Add BenchmarkSortMap a2a4166f6 @bep
  • tpl/collections: Add Merge benchmark 39f582f9f @bep
  • resources/images: Refactor golden image tests to locate them closer to the implementation 2501de7aa @bep
  • resources/images: Add some mask tests 06cc8673f @bep #13244
  • resources/images: Add images.Mask 71fae9918 @trickkiste #13244
  • tpl/tplimpl: Use plain text for image render hook alt attribute 8af04745f @jmooring
  • resources/images: Add some golden tests for images.QR 892b49110 @bep
  • tpl/images: Change signature of images.QR to images.QR TEXT OPTIONS b13d0a68e @jmooring #13230
  • resources/images: Add some golden tests for images.Text d9594a96f @bep
  • images.Text: Add “alignx” option for horizontal alignment 4a5cc2dd2 @jlskuz #10849
  • images: Rework the golden tests 9cad8d38c @bep
  • create: Respect –noBuildLock in hugo new 2a7bb1c7c @bep
  • tpl/images: Format the QR hashes as hex 5f2adad2c @bep
  • tpl/images: Add images.QR function 4ea94c451 @jmooring #13205
  • Add try 5d2cbee98 @bep #9737
  • resources: Add FromOpts for more effective resource creation 723e3f434 @bep
  • markup/highlight: Remove noHl option 2db43f841 @jmooring #9885

Dependency Updates

  • deps: Upgrade github.com/gohugoio/hashstructure from 0.1.0 to 0.3.0 a2edf04c2 @bep
  • build(deps): bump golang.org/x/tools from 0.28.0 to 0.29.0 f024a5050 @dependabot[bot]
  • build(deps): bump golang.org/x/net from 0.33.0 to 0.34.0 80704bc9a @dependabot[bot]
  • build(deps): bump github.com/evanw/esbuild from 0.24.0 to 0.24.2 b7b49fb0f @dependabot[bot]
  • build(deps): bump github.com/alecthomas/chroma/v2 from 2.14.0 to 2.15.0 a83797673 @dependabot[bot]

Documentation

  • docs: Regen CLI docs 88ecc3b75 @bep
  • docs: Regen CLI docs 44628616a @bep

Build Setup

  • snap: Always package latest stable version of Go 3682027a5 @jmooring

下载链接