* 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
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
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
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
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)
```
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 <joe@mooring.com>
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
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
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#653Closes#12282
Co-authored-by: kolappannathan <kolappannathan@users.noreply.github.com>
Co-authored-by: felicianotech <FelicianoTech@gmail.com>
Changes:
- Remove trailing comma from list of keywords.
- Improve keywords precedence:
1. Use "keywords" term page titles.
2. Use "keywords" from front matter if "keywords" is not a taxonomy.
3. Use "tags" term page titles.
4. Use term page titles from all taxonomies.
- Enable schema for all page kinds, previously limited to kind = page.
- Remove trailing slashes from void elements.
- Improve readability.
Closes#7570
Co-authored by: 0urobor0s <0urobor0s@users.noreply.github.com>