summaryrefslogtreecommitdiffstats
path: root/tpl/resources/resources.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-05-24 09:34:36 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-05-25 10:35:31 +0200
commitcd0112a05a9ddb7043c9808284f93d8099c48473 (patch)
tree92da50996ede587f3683fdcfc851ed0325b64998 /tpl/resources/resources.go
parent6f7fbe03b1a70733f00da6556a89250a29e53ec8 (diff)
Add resources.Copy
Implemented by most Resource objects, but not Page (for now). Fixes #9313
Diffstat (limited to 'tpl/resources/resources.go')
-rw-r--r--tpl/resources/resources.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/tpl/resources/resources.go b/tpl/resources/resources.go
index 2adec358c..165152c78 100644
--- a/tpl/resources/resources.go
+++ b/tpl/resources/resources.go
@@ -111,6 +111,15 @@ func (ns *Namespace) getscssClientDartSass() (*dartsass.Client, error) {
return ns.scssClientDartSass, err
}
+// Copy copies r to the new targetPath in s.
+func (ns *Namespace) Copy(s any, r resource.Resource) (resource.Resource, error) {
+ targetPath, err := cast.ToStringE(s)
+ if err != nil {
+ panic(err)
+ }
+ return ns.createClient.Copy(r, targetPath)
+}
+
// Get locates the filename given in Hugo's assets filesystem
// and creates a Resource object that can be used for further transformations.
func (ns *Namespace) Get(filename any) resource.Resource {