tpl/images: Add images.QR function

Closes #13205
This commit is contained in:
Joe Mooring
2024-12-31 17:43:35 -05:00
committed by Bjørn Erik Pedersen
parent 5d2cbee989
commit 4ea94c451d
10 changed files with 495 additions and 28 deletions

View File

@@ -698,3 +698,39 @@ Home!
b.BuildPartial("/mybundle1/")
b.AssertFileContent("public/mybundle1/index.html", "Baseof!!")
}
func TestQRShortcode(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
-- layouts/index.html --
{{ .Content }}
-- content/_index.md --
---
title: home
---
{{< qr
text="https://gohugo.io"
level="high"
scale=4
targetDir="codes"
alt="QR code linking to https://gohugo.io"
class="my-class"
id="my-id"
title="My Title"
/>}}
{{< qr >}}
https://gohugo.io"
{{< /qr >}}
`
b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html",
`<img src="/codes/qr_1933601158373371382.png" width="148" height="148" alt="QR code linking to https://gohugo.io" class="my-class" id="my-id" title="My Title">`,
`<img src="/qr_8288684942309665993.png" width="132" height="132">`,
)
}