From cd0112a05a9ddb7043c9808284f93d8099c48473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 24 May 2022 09:34:36 +0200 Subject: Add resources.Copy Implemented by most Resource objects, but not Page (for now). Fixes #9313 --- tpl/resources/resources.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tpl/resources/resources.go') 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 { -- cgit v1.2.3