hugo-fixit / FixIt

🔧 A clean, elegant but advanced blog theme for Hugo 一个简洁、优雅且高效的 Hugo 主题
https://fixit.lruihao.cn
MIT License
646 stars 96 forks source link

[BUG] Some breaking bugs caused by Hugo 0.123.0 #420

Closed Lruihao closed 4 months ago

Lruihao commented 6 months ago

异常:$params 参数一整个获取异常,原因应该是 Hugo 新版本的深度合并与旧版本不一致导致的。 策略:使用 .Param 方法代替 .Params 参数获取页面参数

The Param method returns the value associated with the given KEY, regardless of whether the value is truthy or falsy.

参考:

Lruihao commented 4 months ago

Why is my page Scratch or Store missing a value?

The Scratch and Store methods on a Page object allow you to create a scratch pad on the given page to store and manipulate data. Values are often set within a shortcode, a partial template called by a shortcode, or by a Markdown render hook. In all three cases, the scratch pad values are not determinate until Hugo renders the page content.

Lruihao commented 4 months ago

Why is my page Scratch or Store missing a value?

The Scratch and Store methods on a Page object allow you to create a scratch pad on the given page to store and manipulate data. Values are often set within a shortcode, a partial template called by a shortcode, or by a Markdown render hook. In all three cases, the scratch pad values are not determinate until Hugo renders the page content.

可以肯定的是造成 typeit 和 mapbox shortcode 失效的主要原因正是因为 Page Scratch 在 shortcode 的阶段是不确定的值。经过各种尝试后依旧没有找到好的解决方式。

放弃!

之后或改用 typed.js,并独立出 FixIt 主题,成为主题组件生态的一部分

Lruihao commented 4 months ago

同时考虑到 目前仍处于 0.3.x 版本的阶段,为减少升级主题造成的影响,page 这层参数仍然保留,先加入待办事项

Scratch 相关的 bug,通过其他方式解决,例如数据储存不放在 scratch 中暂存再给 js 处理了,尝试直接放在 html 中,通过原生 template 标签存储。

Lruihao commented 4 months ago

typeit、echarts、mapbox shortcodes 都已重构为不依赖 .Scratch 实现。