summaryrefslogtreecommitdiffstats
path: root/tpl
AgeCommit message (Collapse)Author
2023-02-22tpl/internal: Sync Go template src to Go 1.20Bjørn Erik Pedersen
Updates #10691
2023-02-21Add page fragments support to RelatedBjørn Erik Pedersen
The main topic of this commit is that you can now index fragments (content heading identifiers) when calling `.Related`. You can do this by: * Configure one or more indices with type `fragments` * The name of those index configurations maps to an (optional) front matter slice with fragment references. This allows you to link page<->fragment and page<->page. * This also will index all the fragments (heading identifiers) of the pages. It's also possible to use type `fragments` indices in shortcode, e.g.: ``` {{ $related := site.RegularPages.Related .Page }} ``` But, and this is important, you need to include the shortcode using the `{{<` delimiter. Not doing so will create infinite loops and timeouts. This commit also: * Adds two new methods to Page: Fragments (can also be used to build ToC) and HeadingsFiltered (this is only used in Related Content with index type `fragments` and `enableFilter` set to true. * Consolidates all `.Related*` methods into one, which takes either a `Page` or an options map as its only argument. * Add `context.Context` to all of the content related Page API. Turns out it wasn't strictly needed for this particular feature, but it will soon become usefil, e.g. in #9339. Closes #10711 Updates #9339 Updates #10725
2023-02-08tpl/collections: Improve error message in IndexBjørn Erik Pedersen
2023-02-05tpl/strings: Add strings.ContainsNonSpaceBjørn Erik Pedersen
2023-01-31Fix description of collections.UniqJoe Mooring
2023-01-25Only invoke a given cached partial onceBjørn Erik Pedersen
Note that this is backed by a LRU cache (which we soon shall see more usage of), so if you're a heavy user of cached partials it may be evicted and refreshed if needed. But in most cases every partial is only invoked once. This commit also adds a timeout (the global `timeout` config option) to make infinite recursion in partials easier to reason about. ``` name old time/op new time/op delta IncludeCached-10 8.92ms ± 0% 8.48ms ± 1% -4.87% (p=0.016 n=4+5) name old alloc/op new alloc/op delta IncludeCached-10 6.65MB ± 0% 5.17MB ± 0% -22.32% (p=0.002 n=6+6) name old allocs/op new allocs/op delta IncludeCached-10 117k ± 0% 71k ± 0% -39.44% (p=0.002 n=6+6) ``` Closes #4086 Updates #9588
2023-01-17tpl/strings: Add findRESubmatchBjørn Erik Pedersen
Fixes #10594
2023-01-04Misc doc, code refactoring to improve documentationBjørn Erik Pedersen
2023-01-04Make readFile return nil when file not found (note)Bjørn Erik Pedersen
Fixes #9620
2023-01-02tpl/compare: Sort special float values as stringacclassic
When sorting strings a worng order is returned. This happens because the strings are first converted to floating values to check whether or not they should be sorted as floating values. When an error is returned the strings will be handled as string literals. No error will be returned when parsing Inf, Infinity or NaN (case insensitive) because they will be coverted to special floating point values and therefore are legal float values. Now we check if the returned converted values are special floating values and treat them as string literals. Fixes #10389
2022-12-25tpl/diagrams: Move Goat to its own fileBjørn Erik Pedersen
2022-12-22Revert "tpl/tplimpl: Use https in sitemap templates"Joe Mooring
This reverts commit 3fd0b78498597ceb343b7fda2e9b652f3e957478.
2022-12-21tpl: Improve template funcs GoDocBjørn Erik Pedersen
2022-12-21tpl/resources: Fix data race in ToCSSBjørn Erik Pedersen
Fixes #10542
2022-12-14Also consider wrapped errors when checking for file IsNotExist errorsBjørn Erik Pedersen
Fixes #10534
2022-12-14tpl/openapi3: Wrap *kopenapi3.TBjørn Erik Pedersen
To make it easier to document.
2022-12-11tpl/tplimpl: Use https in sitemap templatesJoe Mooring
Closes #10515
2022-12-06tpl/embedded: Make Open Graph's series optionalRazon Yang
2022-12-04tpl/tplimpl: Allow alternate comment syntaxJoe Mooring
Allow alternate comment syntax before block definitions: {{/* foo */}} {{- /* foo */}} {{- /* foo */ -}} Fixes #10495
2022-12-03tpl/collections: Fix some index cases where the indices given is a slice and ↵Bjørn Erik Pedersen
be more lenient with nil inputs See adjusted tests for detail. Fixes #10489
2022-12-03tpl: Misco GoDoc improvementsBjørn Erik Pedersen
2022-11-25tpl: Use consistent delimiter spacing in examplesJoe Mooring
2022-11-24Add a cache for lexers.GetBjørn Erik Pedersen
``` name old time/op new time/op delta Codeblocks/Default-10 152ms ±11% 12ms ± 1% -92.44% (p=0.029 n=4+4) Codeblocks/Hook_no_higlight-10 142ms ± 0% 7ms ± 0% -95.36% (p=0.029 n=4+4) name old alloc/op new alloc/op delta Codeblocks/Default-10 11.9MB ± 0% 11.7MB ± 0% -1.59% (p=0.029 n=4+4) Codeblocks/Hook_no_higlight-10 4.62MB ± 1% 4.43MB ± 0% -4.08% (p=0.029 n=4+4) name old allocs/op new allocs/op delta Codeblocks/Default-10 209k ± 0% 209k ± 0% -0.03% (p=0.029 n=4+4) Codeblocks/Hook_no_higlight-10 68.4k ± 0% 68.3k ± 0% -0.06% (p=0.029 n=4+4) ```
2022-11-17resources/tpl: Add a test for resources.GetBjørn Erik Pedersen
Updates #10101
2022-11-17tlp/resources: resources.Get returns nil when given empty stringshifterbit
2022-11-14tpl/internal: Sync go_templatesBjørn Erik Pedersen
Closes #10411
2022-10-26media: Rename application/javascript, application/typescript to ↵Bjørn Erik Pedersen
text/javascript etc. The former is deprecated. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types See https://discourse.gohugo.io/t/mime-type-for-javascript-is-now-text-javascript/40813
2022-10-24tpl/encoding: Add noHTMLEscape option to jsonifyBjørn Erik Pedersen
2022-08-26deps: Update github.com/pelletier/go-toml/v2 v2.0.2 => v2.0.4Bjørn Erik Pedersen
Closes #10210
2022-07-13Cache when not found in LookupLayoutBjørn Erik Pedersen
Very visible when using the pprof mutex profiler. ```bash name old time/op new time/op delta Baseline-10 58.4ms ± 1% 51.6ms ± 0% -11.56% (p=0.029 n=4+4) name old alloc/op new alloc/op delta Baseline-10 64.3MB ± 0% 64.2MB ± 0% ~ (p=0.114 n=4+4) name old allocs/op new allocs/op delta Baseline-10 649k ± 0% 649k ± 0% ~ (p=0.229 n=4+4) ```
2022-06-14deps: Udpate to github.com/alecthomas/chroma/v2Bjørn Erik Pedersen
Fixes #9932 Fixes #9931
2022-06-07Fix raw TOML dates in where/eqBjørn Erik Pedersen
Note that this has only been a problem with "raw dates" in TOML files in /data and similar. The predefined front matter dates `.Date` etc. are converted to a Go Time and has worked fine even after upgrading to v2 of the go-toml lib. Fixes #9979
2022-06-06tpl/path: Add path.BaseName functionJoe Mooring
Closes #9973
2022-05-31Fix indentation in highlight shortcodeBjørn Erik Pedersen
This commit adds a new `.InnerDeindent` method to the shortcode context, which is `.Inner` with any indendation removed. This is then used in the built-in `highlight` shortcode to prevent the extra whitespace getting hightlighted. Fixes #4717
2022-05-27postcss: Make the resource cache key more stableBjørn Erik Pedersen
By using the input map as the basis, which means the hash will not change if we add/rename/remove options. This happened in Hugo 0.99, as we added a new options. This is unortunate. Unfortunately this means that the cache keys for PostCSS will change one more time in 0.100, but will be stable going forward. Note that we have implemented this pattern in all the other resource transformers. Updates #9787
2022-05-25Fix Plainify edge casesBjørn Erik Pedersen
This commit replaces the main part of `helpers.StripHTML` with Go's implementation in its html/template package. It's a little slower, but correctness is more important: ```bash BenchmarkStripHTMLOld-10 680316 1764 ns/op 728 B/op 4 allocs/op BenchmarkStripHTMLNew-10 384520 3099 ns/op 2089 B/op 10 allocs/op ``` Fixes #9199 Fixes #9909 Closes #9410
2022-05-25Add resources.CopyBjørn Erik Pedersen
Implemented by most Resource objects, but not Page (for now). Fixes #9313
2022-05-15Improve SASS errorsBjørn Erik Pedersen
Fixes #9897
2022-05-15postcss: Fix import error handlingBjørn Erik Pedersen
Note that we will now fail if `inlineImports` is enabled and we cannot resolve an import. You can work around this by either: * Use url imports or imports with media queries. * Set `skipInlineImportsNotFound=true` in the options Also get the argument order in the different NewFileError* funcs in line. Fixes #9895
2022-05-14errors: Misc improvementsBjørn Erik Pedersen
* Redo the server error template * Always add the content file context if relevant * Remove some now superflous error string matching * Move the server error template to _server/error.html * Add file context (with position) to codeblock render blocks * Improve JS build errors Fixes #9892 Fixes #9891 Fixes #9893
2022-05-09Revise the use of htime.Since/htime.NowBjørn Erik Pedersen
We cannot (also, it doesn't add any value) use that when the `clock` is set, * To measure time (before that global is set) * To compare file timestamps re cache eviction Fixes #9868
2022-05-08tpl/collections: Make sort stableBjørn Erik Pedersen
Fixes #9865
2022-05-08Use configured timeZone for the clockBjørn Erik Pedersen
And some other related adjustments. Updates #8787
2022-05-08Add `clock` cli flagsatotake
Close #8787
2022-05-06Improve error messages, esp. when the server is runningBjørn Erik Pedersen
* Add file context to minifier errors when publishing * Misc fixes (see issues) * Allow custom server error template in layouts/server/error.html To get to this, this commit also cleans up and simplifies the code surrounding errors and files. This also removes the usage of `github.com/pkg/errors`, mostly because of https://github.com/pkg/errors/issues/223 -- but also because most of this is now built-in to Go. Fixes #9852 Fixes #9857 Fixes #9863
2022-05-06tpl: Improve godocBjørn Erik Pedersen
2022-04-28tpl/crypto: Add example for FNV32aBjørn Erik Pedersen
2022-04-27Some godoc adjustments and image struct renamesBjørn Erik Pedersen
2022-04-27tpl/crypto: Add FNV32aBjørn Erik Pedersen
Main motivation to get a integer from a string.
2022-04-23Some godoc adjustmentsBjørn Erik Pedersen