diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-02-24 07:23:10 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-02-24 10:40:06 +0100 |
commit | 271318ad787ee2442c6d553edffaa29e1d9a4cf7 (patch) | |
tree | 4314daa1667ecb7badff421a5c19e51f5ea7bc4f /hugolib/content_render_hooks_test.go | |
parent | e442a63bb7659d95aec2d48bf954cd9d61163559 (diff) | |
download | hugo-271318ad787ee2442c6d553edffaa29e1d9a4cf7.tar.gz hugo-271318ad787ee2442c6d553edffaa29e1d9a4cf7.zip |
Split parse and render for Goldmark
This also speeds up situations where you only need the fragments/toc and not the rendered content, e.g. Related
with fragments type indexing:
```bash
name old time/op new time/op delta
RelatedSite-10 12.3ms ± 2% 10.7ms ± 1% -12.95% (p=0.029 n=4+4)
name old alloc/op new alloc/op delta
RelatedSite-10 38.6MB ± 0% 38.2MB ± 0% -1.08% (p=0.029 n=4+4)
name old allocs/op new allocs/op delta
RelatedSite-10 117k ± 0% 115k ± 0% -1.36% (p=0.029 n=4+4)
```
Fixes #10750
Diffstat (limited to 'hugolib/content_render_hooks_test.go')
-rw-r--r-- | hugolib/content_render_hooks_test.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/hugolib/content_render_hooks_test.go b/hugolib/content_render_hooks_test.go index dbfd46459..5b2121ef8 100644 --- a/hugolib/content_render_hooks_test.go +++ b/hugolib/content_render_hooks_test.go @@ -427,3 +427,52 @@ Image: <p>html-image: image.jpg|Text: Hello<br> Goodbye|Plain: Hello GoodbyeEND</p> `) } + +func TestRenderHookContentFragmentsOnSelf(t *testing.T) { + files := ` +-- hugo.toml -- +baseURL = "https://example.org" +disableKinds = ["taxonomy", "term", "RSS", "sitemap", "robotsTXT"] +-- content/p1.md -- +--- +title: "p1" +--- + +## A {#z} +## B +## C + +-- content/p2.md -- +--- +title: "p2" +--- + +## D +## E +## F + +-- layouts/_default/_markup/render-heading.html -- +Heading: {{ .Text }}| +Self Fragments: {{ .Page.Fragments.Identifiers }}| +P1 Fragments: {{ (site.GetPage "p1.md").Fragments.Identifiers }}| +-- layouts/_default/single.html -- +{{ .Content}} +` + + b := NewIntegrationTestBuilder( + IntegrationTestConfig{ + T: t, + TxtarString: files, + }, + ).Build() + + b.AssertFileContent("public/p1/index.html", ` +Self Fragments: [b c z] +P1 Fragments: [b c z] + `) + b.AssertFileContent("public/p2/index.html", ` +Self Fragments: [d e f] +P1 Fragments: [b c z] + `) + +} |