Bjørn Erik Pedersen
07983e04e2
tpl: Fix it so we always prefer internal codeblock rendering over render-codeblock-foo.html and similar
...
Test / test (1.23.x, windows-latest) (push) Waiting to run
Test / test (1.24.x, ubuntu-latest) (push) Waiting to run
Test / test (1.24.x, windows-latest) (push) Waiting to run
Test / test (1.23.x, ubuntu-latest) (push) Waiting to run
Fixes #13651
2025-04-25 10:51:33 +02:00
Joe Mooring
5c491409d3
tpl/tplimpl: Fix allowFullScreen option in Vimeo and YouTube shortcodes
...
Test / test (1.23.x, ubuntu-latest) (push) Waiting to run
Test / test (1.23.x, windows-latest) (push) Waiting to run
Test / test (1.24.x, ubuntu-latest) (push) Waiting to run
Test / test (1.24.x, windows-latest) (push) Waiting to run
Closes #13650
2025-04-24 14:14:46 -07:00
Bjørn Erik Pedersen
ad4f63c92f
tpl: Remove some unreached code branches
2025-04-24 14:27:59 +02:00
Christian Oliff
6a0e04241a
all: Fix typos
2025-04-24 10:19:17 +02:00
Bjørn Erik Pedersen
496730840e
Revert the breaking change from 0.146.0 with dots in content filenames
...
Closes #13632
2025-04-22 19:23:19 +02:00
Bjørn Erik Pedersen
6d69dc88a4
tpl: Fix indeterminate template lookup with templates with and without lang
...
Close #13636
2025-04-22 17:29:39 +02:00
Joe Mooring
db72a1f075
parser/metadecoders: Add CSV targetType (map or slice) option to transform.Unmarshal
...
Closes #8859
2025-04-21 19:33:20 +02:00
Bjørn Erik Pedersen
4eb0e4286a
tpl/collections: Fix where ... not in with empty slice
...
Fixes #13621
2025-04-21 15:17:20 +02:00
Bjørn Erik Pedersen
5e62cc6fce
tpl: Fix layout fall back logic when layout is set in front matter but not found
...
Fixes #13630
2025-04-21 15:17:20 +02:00
Bjørn Erik Pedersen
1408c156d8
tpl: Detect and fail on infinite template recursion
...
Fixes #13627
2025-04-21 15:17:20 +02:00
Bjørn Erik Pedersen
088cd2f996
tpl: Fix when layout specified in front matter and no match is found
...
Fixes #13628
2025-04-20 12:55:18 +02:00
Bjørn Erik Pedersen
d61b9fc605
tpl: Fix language handling in partials
...
We now use the same code path for all templates re this.
Fixes #13612
2025-04-15 11:25:54 +02:00
Bjørn Erik Pedersen
65c94c7b23
tpl: Fix issue with partials without suffix
...
Fixes #13601
2025-04-14 14:38:22 +02:00
Bjørn Erik Pedersen
e8e8ce10d2
tpl: Avoid panic on nonsensical return construct
...
Fixes #13600
2025-04-14 14:38:22 +02:00
Bjørn Erik Pedersen
cf9e6904cc
tpl: Fix the case for a shortcode in a nested folder only
...
Fixes #13605
2025-04-14 14:38:22 +02:00
Bjørn Erik Pedersen
8a2830f2dc
tpl: Add proper file context to template parse errors
...
Fixes #13604
2025-04-14 14:38:22 +02:00
Bjørn Erik Pedersen
1e0287f472
tpl: Make {{ template "partials/foo.html" . }} work in older setups
...
Fixes #13599
2025-04-14 14:38:22 +02:00
Bjørn Erik Pedersen
30b9c19c76
tpl: Make any layout set in front matter higher priority
...
Fixes #13541
2025-04-12 18:12:06 +02:00
Bjørn Erik Pedersen
c8710625b7
tpl: Fix it so embedded render-codeblock-goat is used even if custom render-codeblock exists
...
Fixes #13595
2025-04-12 13:03:45 +02:00
Bjørn Erik Pedersen
d1c394442b
tpl: Fix codeblock hook resolve issue
...
Fixes #13593
2025-04-11 18:59:42 +02:00
Bjørn Erik Pedersen
1074e01152
tpl: Fix legacy section mappings
...
Fixes #13584
2025-04-11 18:23:51 +02:00
Bjørn Erik Pedersen
c19f1f2363
tpl: Resolve layouts/all.html for all html output formats
...
Fixes #13587
2025-04-11 18:23:51 +02:00
Bjørn Erik Pedersen
9221cbca49
tpl: Fix some baseof lookup issues
...
We were mistakingly using the templates (e.g. list.html) descriptor to resolve the base template and not the page,
which worked fine in most cases, but not all.
Fixes #13583
2025-04-11 18:23:51 +02:00
Bjørn Erik Pedersen
3b9f2a7ded
tpl: Skip dot and temp files inside /layouts
...
Fixes #13579
2025-04-10 18:41:01 +02:00
Bjørn Erik Pedersen
383dd82f95
tpl: Warn and skip non-hook templates inside /layouts/_markup
...
Fixes #13577
2025-04-10 16:54:05 +02:00
Bjørn Erik Pedersen
208a0de6c3
tpl: Add a partial lookup cache
...
````
│ stash.bench │ perf-v146.bench │
│ sec/op │ sec/op vs base │
LookupPartial-10 248.00n ± 0% 14.75n ± 2% -94.05% (p=0.002 n=6)
│ stash.bench │ perf-v146.bench │
│ B/op │ B/op vs base │
LookupPartial-10 48.00 ± 0% 0.00 ± 0% -100.00% (p=0.002 n=6)
│ stash.bench │ perf-v146.bench │
│ allocs/op │ allocs/op vs base │
LookupPartial-10 3.000 ± 0% 0.000 ± 0% -100.00% (p=0.002 n=6)
```
THe speedup above assumes reuse of the same partials over and over again, which I think is not uncommon.
This commits also adds some more lookup benchmarks. The current output of these on my MacBook looks decent:
```
BenchmarkLookupPagesLayout/Single_root-10 3031562 395.5 ns/op 0 B/op 0 allocs/op
BenchmarkLookupPagesLayout/Single_sub_folder-10 2515915 480.9 ns/op 0 B/op 0 allocs/op
BenchmarkLookupPartial-10 84808112 14.13 ns/op 0 B/op 0 allocs/op
BenchmarkLookupShortcode/toplevelpage-10 8111779 148.2 ns/op 0 B/op 0 allocs/op
BenchmarkLookupShortcode/nestedpage-10 8088183 148.6 ns/op 0 B/op 0 allocs/op
```
Note that in the above the partial lookups are cahced, the others not (they are harder to cache because of the page path).
Closes #13571
2025-04-10 11:07:19 +02:00
Bjørn Erik Pedersen
d4c6dd16b1
tpl: Add templates.Current
...
This commit also
* Unexport all internal state in TemplateInfo.
* Make the dispatcher keys used for passing context.Context into uint8 from string to save memory allocations.
Co-authored-by: Joe Mooring <joe@mooring.com>
Updates #13571
2025-04-09 20:15:40 +02:00
Joe Mooring
1e00842489
tpl/tplimpl: Update embedded pagination template
2025-04-07 21:29:53 +02:00
Bjørn Erik Pedersen
83cfdd78ca
Reimplement and simplify Hugo's template system
...
See #13541 for details.
Fixes #13545
Fixes #13515
Closes #7964
Closes #13365
Closes #12988
Closes #4891
2025-04-06 20:59:41 +02:00
Joe Mooring
07cbe5701e
tpl/time: Add time.In function
...
Closes #13548
2025-04-03 09:45:51 +02:00
Joe Mooring
6f14dbe24c
tpl/tplimpl: Fix full screen option in vimeo and youtube shortcodes
...
Closes #13531
Co-authored-by: Stefan Ritter <60473875+gideonstar-git@users.noreply.github.com>
2025-03-27 12:32:00 +01:00
Joe Mooring
b9add1c702
tpl/tplimpl: Add loading attribute to Vimeo shortcode
...
Closes #13445
2025-03-11 21:02:12 +01:00
Will Faught
eebea9ec41
tpl: Add trailing newline to robots.txt template
2025-03-05 15:02:50 +01:00
Bjørn Erik Pedersen
521911a576
all: Run modernize -fix ./...
2025-02-26 11:44:25 +01:00
Christian Oliff
2f4e666d7e
tpl: HTTPS the instagram Shortcode JS
...
This JavaScript will always load over HTTPS so it's best to specify that. Protocol-less loaded resources are an anti-pattern (REF: https://www.paulirish.com/2010/the-protocol-relative-url/ )
2025-02-26 09:27:31 +01:00
Bjørn Erik Pedersen
04f21b4d80
Add transform.PortableText
...
Using this in a content adapter could look like this:
```handlebars
{{ $projectID := "<myproject>" }}
{{ $useCached := true }}
{{ $api := "api" }}
{{ if $useCached }}
{{/* See https://www.sanity.io/docs/api-cdn */}}
{{ $api = "apicdn" }}
{{ end }}
{{ $url := printf "https://%s.%s.sanity.io/v2021-06-07/data/query/production " $projectID $api }}
{{/* prettier-ignore-start */ -}}
{{ $q := `*[_type == 'post']{
title, publishedAt, summary, slug, body[]{
...,
_type == "image" => {
...,
asset->{
_id,
path,
url,
altText,
title,
description,
metadata {
dimensions {
aspectRatio,
width,
height
}
}
}
}
},
}`
}}
{{/* prettier-ignore-end */ -}}
{{ $body := dict "query" $q | jsonify }}
{{ $opts := dict "method" "post" "body" $body }}
{{ $t := debug.Timer "sanity.get" }}
{{ $r := resources.GetRemote $url $opts }}
{{ $t.Stop }}
{{ $m := $r | transform.Unmarshal }}
{{ $result := $m.result }}
{{ $t := debug.Timer "sanity.parse" }}
{{ range $result }}
{{ if not .slug }}
{{ continue }}
{{ end }}
{{ $markdown := transform.PortableText .body }}
{{ $t.Stop }}
{{ $content := dict
"mediaType" "text/markdown"
"value" $markdown
}}
{{ $params := dict
"portabletext" (.body | jsonify (dict "indent" " "))
}}
{{ $page := dict
"content" $content
"kind" "page"
"path" .slug.current
"title" .title
"date" (.publishedAt | time )
"summary" .summary
"params" $params
}}
{{ $.AddPage $page }}
{{ end }}
```
2025-02-25 19:35:47 +01:00
Bjørn Erik Pedersen
641403f7de
Fix Position for passthrough hooks
...
Fixes #13406
2025-02-17 12:23:49 +01:00
Bjørn Erik Pedersen
fd8b0fbf8a
Upgrade to Go 1.24
...
Fixes #13381
2025-02-12 22:01:25 +01:00
Bjørn Erik Pedersen
9b5f786df8
Deprecate kind, lang, and path from front matter
...
These were added to the page meta object when we implemented "pages from data", but were not meant to be used in front matter.
That is not supported, so we might as well add validation.
Fixes #12484
2025-02-10 21:22:43 +01:00
Bjørn Erik Pedersen
c2fb221209
Add ContentTypes to config
...
This is an empty struct for now, but we will most likely expand on that.
```
[contentTypes]
[contentTypes.'text/markdown']
```
The above means that only Markdown will be considered a content type. E.g. HTML will be treated as plain text.
Fixes #12274
2025-02-08 10:31:15 +01:00
Joe Mooring
7104de83ce
common/hugo: Adjust deprecation timing and message
...
Closes #13333
2025-02-03 18:32:30 +01:00
Alex Shpak
13b208e2f7
tpl/tplimpl: Remove leading whitespaces produced by Youtube shortcode
2025-01-31 09:29:10 +01:00
Joe Mooring
873a5cda1a
tpl/tplimpl: Improve shortcode test coverage
2025-01-24 09:10:45 +01:00
Joe Mooring
f42a4b6af5
tpl/tplimpl: Deprecate gist shortcode
...
Closes #13211
2025-01-23 20:12:36 +01:00
Bjørn Erik Pedersen
51bb2fedab
tpl/tplimpl: Skip TestTemplateFuncsExamples on s390x
...
Closes #13204
2025-01-23 10:18:43 +01:00
Joe Mooring
77a8e347bc
tpl/tplimpl: Deprecate comment shortcode
2025-01-22 19:38:02 +01:00
Joe Mooring
8de4ffb294
tpl/tplimpl: Fix context in shortcode error messages
...
Fixes #13279
2025-01-20 16:17:55 +01:00
Bjørn Erik Pedersen
1f5a15aba0
resources: Fix 2 image file cache key issues
...
* Always include the content hash in the cache key for unprocessed images.
* Always include the image config hash in the cache key.
This is also a major cleanup/simplification of the implementation in this area.
Note that this, unfortunately, forces new hashes/filenames for generated images.
Fixes #13273
Fixes #13272
2025-01-18 12:23:18 +01:00
Nicolas Friedli
8897113666
tpl: Add loading attribute to qr shortcode
2025-01-17 19:06:54 +01:00
Bjørn Erik Pedersen
1fad3832a9
tpl/tplimpl: Simplify some test assertions
2025-01-16 11:29:24 +01:00