aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl
AgeCommit message (Collapse)Author
2024-08-14tpl/transform: Don't run ToMath tests in parallelBjørn Erik Pedersen
Closes #12765
2024-08-12Improve Katex error handling and fix handling of large expressionsBjørn Erik Pedersen
* Make throwOnError=true the new default * Handle JS errors as part of the RPC request/response flow * Return a new Result type with .Err on it This enables constructs on the form: ```handlebars {{ with transform.ToMath "c = \\foo{a^2 + b^2}" }} {{ with .Err }} {{ warnf "error: %s" . }} {{ else }} {{ . }} {{ end }} {{ end }} ``` Note that the new `Result` type behaves like `template.HTML` (or a string if needed) when printed, but it will panic if in a error state. Closes #12748
2024-08-11Add katex option ThrowOnErrorBjørn Erik Pedersen
As an internal option for now. Katex misbehaves in error situations without a value set.
2024-08-11Add some more KaTeX optionsBjørn Erik Pedersen
And fix the options handling. Closes #12745 Fixes #12746
2024-08-11tpl/transform: Make Plainify and ToMath return template.HTMLBjørn Erik Pedersen
None of these are useful as plain strings in the templates, which forces the users to do `transform.Plainify "foo" | safeHTML`. If people have trust issues with the output of these functions, they need to just stop using them. Closes #8732
2024-08-10Fix compare of uints and ints in eq, gt etc.Bjørn Erik Pedersen
Fixes #12733
2024-08-09Add build time math renderingBjørn Erik Pedersen
While very useful on its own (and combined with the passthrough render hooks), this also serves as a proof of concept of using WASI (WebAssembly System Interface) modules in Hugo. This will be marked _experimental_ in the documentation. Not because it will be removed or changed in a dramatic way, but we need to think a little more how to best set up/configure similar services, define where these WASM files gets stored, maybe we can allow user provided WASM files plugins via Hugo Modules mounts etc. See these issues for more context: * https://github.com/gohugoio/hugo/issues/12736 * https://github.com/gohugoio/hugo/issues/12737 See #11927
2024-08-06tpl/cast: Improve floatBjørn Erik Pedersen
Make it support the new upstream rational number type in Exif. See #12718
2024-08-06Skip TestEchoParamBjørn Erik Pedersen
Is deprecated, will be remvoved soon.
2024-08-05Fix deprecation errorsBjørn Erik Pedersen
2024-08-01resources/page: Expand parmalinks tokens in `url`n1xx1
This change allows to use permalink tokens in url front matter fields. This should be useful to target more specific pages instead of using a global permalink configuration. It's expected to be used with cascade. Fixes #9714
2024-08-01Bump to go 1.21 in go.modBjørn Erik Pedersen
2024-08-01tpl: Sync Go template packages with the Go 1.22.5 sourceBjørn Erik Pedersen
2024-07-31Shorten processed image filenamesBjørn Erik Pedersen
Fixes #12688 Fixes #12656
2024-07-31Consolidate all hashing to the common/hashing packageBjørn Erik Pedersen
And remove now unsued hashing funcs.
2024-07-31Replace the MD5 hashing of images with xxHashBjørn Erik Pedersen
Note that we only use this for change detection. The previous implementation invoked `MD5FromReaderFast` that created a MD5 has from 8 64 bytes chunks in the file, which is obviously very fast. The new implementation creates the hash from the entire file and ... seems to be even more effective: ``` name old time/op new time/op delta HashImage-10 9.45µs ±21% 10.89µs ± 1% ~ (p=0.343 n=4+4) name old alloc/op new alloc/op delta HashImage-10 144B ± 0% 8B ± 0% -94.44% (p=0.029 n=4+4) name old allocs/op new allocs/op delta HashImage-10 4.00 ± 0% 1.00 ± 0% -75.00% (p=0.029 n=4+4) ```
2024-07-31identity: Upgrade to github.com/mitchellh/hashstructure/v2 v2.0.2Bjørn Erik Pedersen
``` name old time/op new time/op delta HashString/n28-10 131ns ± 7% 133ns ±19% ~ (p=0.343 n=4+4) HashString/n112-10 237ns ± 5% 241ns ± 3% ~ (p=0.229 n=4+4) HashString/n448-10 688ns ± 3% 687ns ± 1% ~ (p=0.886 n=4+4) HashString/n1792-10 2.51µs ± 3% 2.56µs ± 3% ~ (p=0.200 n=4+4) HashString/n7168-10 10.1µs ± 2% 10.0µs ± 4% ~ (p=0.686 n=4+4) name old alloc/op new alloc/op delta HashString/n28-10 80.0B ± 0% 80.0B ± 0% ~ (all equal) HashString/n112-10 160B ± 0% 160B ± 0% ~ (all equal) HashString/n448-10 496B ± 0% 496B ± 0% ~ (all equal) HashString/n1792-10 1.84kB ± 0% 1.84kB ± 0% ~ (all equal) HashString/n7168-10 8.24kB ± 0% 8.24kB ± 0% ~ (all equal) name old allocs/op new allocs/op delta HashString/n28-10 4.00 ± 0% 4.00 ± 0% ~ (all equal) HashString/n112-10 4.00 ± 0% 4.00 ± 0% ~ (all equal) HashString/n448-10 4.00 ± 0% 4.00 ± 0% ~ (all equal) HashString/n1792-10 4.00 ± 0% 4.00 ± 0% ~ (all equal) HashString/n7168-10 4.00 ± 0% 4.00 ± 0% ~ (all equal) ``` Closes #11644
2024-07-29math: Add trigonometric functions and some angle helper functionsraoulb
This commit adds these new template functions in the `math` namespace: math.Acos math.Asin math.Atan math.Atan2 math.Cos math.Pi math.Sin math.Tan math.ToDegrees math.ToRadians Co-authored-by: Joe Mooring <[email protected]>
2024-07-17tpl: Use xxHash instead of MD5 to hash the deferred templatesBjørn Erik Pedersen
Motivation is performance. These templates are typically very small, so the win is minor, I guess.
2024-07-17Throw error if resources.PostProcess is used in a deferred templateBjørn Erik Pedersen
That just doesn't work. See #12655
2024-07-06Add hash.XxHashBjørn Erik Pedersen
Also move the non crypto hash funcs into this new package. This is much faster than e.g. MD5, especially for larger inputs: ``` BenchmarkXxHash/xxHash_43-10 9917955 112.2 ns/op 56 B/op 4 allocs/op BenchmarkXxHash/mdb5_43-10 6017239 204.1 ns/op 96 B/op 3 allocs/op BenchmarkXxHash/fnv32a_43-10 14407333 82.30 ns/op 16 B/op 1 allocs/op BenchmarkXxHash/xxHash_4300-10 2916892 409.7 ns/op 56 B/op 4 allocs/op BenchmarkXxHash/mdb5_4300-10 159748 7491 ns/op 4912 B/op 3 allocs/op BenchmarkXxHash/fnv32a_4300-10 218210 5510 ns/op 16 B/op 1 allocs/op ``` Fixes #12635
2024-06-25Add css.TailwindCSSBjørn Erik Pedersen
Closes #12618 Closes #12620
2024-06-25Clean up the css related template funcs package structureBjørn Erik Pedersen
Deprecate and move: * resources.ToCSS => css.SASS * resources.PostProcess => css.PostProcess * resources.Babel => js.Babel Updates #12618
2024-06-24tpl/debug: Fix reset of debug timers when running the serverBjørn Erik Pedersen
Fixes #12621
2024-06-23Implement deferBjørn Erik Pedersen
Closes #8086 Closes #12589
2024-06-22Fix Erroridf/Warnidf mixed case issueBjørn Erik Pedersen
Fixes #12617
2024-06-04Add a HTTP cache for remote resources.Bjørn Erik Pedersen
Fixes #12502 Closes #11891
2024-05-21tpl/tplimpl: Resolve render hook destinations with leading ./Joe Mooring
Closes #12514
2024-05-14tpl/tplimpl: Plainify title and description in twitter_cards.htmlJoe Mooring
Closes #12433 Improves #10900
2024-05-14tpl/tplimpl: Plainify title and description in schema.htmlJoe Mooring
Closes #12432
2024-05-14Create pages from _content.gotmplBjørn Erik Pedersen
Closes #12427 Closes #12485 Closes #6310 Closes #5074
2024-05-14tpl/tplimpl: Improve locale value in opengraph.htmlJoe Mooring
Closes #12480
2024-05-10tpl/tplimpl: Retain query string and fragment in render-image.htmlJoe Mooring
Closes #12468
2024-05-04Make the cache eviction logic for stale entities more robustBjørn Erik Pedersen
Fixes #12458
2024-04-25Fix rebuilds when running hugo -wBjørn Erik Pedersen
This was partly broken in Hugo 0.123.0. We have two internal config options that gets set from the CLI: * Running; a web server is running * Watching; either set via `hugo -w` or `hugo server --watch=false` Part of the change detection code wrongly used the `Running` as a flag when `Watching` would be the correct. Fixes #12296
2024-04-25tpl/tplimpl: Fix double-escaping in opengraph templateJoe Mooring
Closes #12418
2024-04-22tpl: Escape .Title in built-in image and link render hooksBjørn Erik Pedersen
Co-authored-by: Joe Mooring <[email protected]>
2024-04-22tpl/tplimpl: Improve embedded templatesJoe Mooring
- Do not call the YouTube oEmbed API - Do not include the Hugo version in RSS feeds Closes #12396
2024-04-18tpl: Use erroridf for remote YouTube errorsBjørn Erik Pedersen
So they can be silenced. Fixes #12383
2024-04-15Pass .RenderShortcodes' Page to render hooks as .PageInnerBjørn Erik Pedersen
The main use case for this is to resolve links and resources (e.g. images) relative to the included `Page`. A typical `include` would similar to this: ```handlebars {{ with site.GetPage (.Get 0) }} {{ .RenderShortcodes }} {{ end }} ``` And when used in a Markdown file: ```markdown {{% include "/posts/p1" %}} ``` Any render hook triggered while rendering `/posts/p1` will get `/posts/p1` when calling `.PageInner`. Note that * This is only relevant for shortcodes included with `{{%` that calls `.RenderShortcodes`. * `.PageInner` is available in all render hooks that, before this commit, received `.Page`. * `.PageInner` will fall back to the value of `.Page` if not relevant and will always have a value. Fixes #12356
2024-04-14helpers: Fix TrimShortHTML when used with AsciiDoc contentJoe Mooring
Fixes #12369
2024-04-11all: Fix duplicate words in commentsEitan Adler
2024-04-04tpl/strings: Improve type checkingJoe Mooring
2024-04-04tpl/tplimpl: Improve youtube shortcodeJoe Mooring
Changes: - Add query string params for controls, loop, mute, start, and end - Add iframe loading attribute - Obtain default iframe title from YouTube oEmbed API - Fix autoplay feature - Improve readability Closes #3694 Closes #9213 Closes #10520 Closes #10575 Closes #10576 Co-authored-by: sgharms <[email protected]>
2024-04-04errors: Return error from cast.ToStringE() consistentlyseiya
2024-04-02tpl/tplimpl: Improve embedded opengraph templateJoe Mooring
Changes: - Add tags per documentation - Prefer site.Title over site.Params.title - Plainify titles, tags, and descriptions - Add fallback values for locale - Fix pages related by series - Improve readability Closes #8296 Closes #8698 Closes #8991 Closes #9818 Closes #9866 Closes #10647 Co-authored-by: tomy0000000 <[email protected]> Co-authored-by: sean-au <[email protected]>
2024-04-02tpl/strings: Create strings.Diff template functionJoe Mooring
Closes #12330
2024-04-02tpl/tplimpl: Optionally exclude content from sitemapJoe Mooring
Define global inclusion/exclusion in site configuration, and override via front matter. For example, to exclude a page from the sitemap: [sitemap] disable = true # default is false Closes #653 Closes #12282 Co-authored-by: kolappannathan <[email protected]> Co-authored-by: felicianotech <[email protected]>
2024-04-01tpl/tplimpl: Remove trailing slash from void elementsJoe Mooring
Closes #11867
2024-03-30tpl/tplimpl: Update RSS templateJoe Mooring
- Use publication date for pubdate - Include version in generator element Closes #3918 Closes #11692