resource

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace provides template functions for the "resources" namespace.

func New

func New(resource Resource) (*Namespace, error)

New returns a new instance of the resources-namespaced template functions.

func (*Namespace) Copy

Copy copies r to the new targetPath in s.

func (*Namespace) ExecuteAsTemplate

func (ns *Namespace) ExecuteAsTemplate(ctx context.Context, args ...any) (resources.Resource, error)

ExecuteAsTemplate creates a Resource from a Go template, parsed and executed with the given data, and published to the relative target path.

func (*Namespace) Fingerprint

func (ns *Namespace) Fingerprint(args ...any) (resources.Resource, error)

Fingerprint transforms the given Resource with a MD5 hash of the content in the RelPermalink and Permalink.

func (*Namespace) Get

func (ns *Namespace) Get(filename any) resources.Resource

Get locates the filename given in Hugo's assets filesystem and creates a Resource object that can be used for further transformations.

func (*Namespace) GetMatch

func (ns *Namespace) GetMatch(pattern any) resources.Resource

GetMatch finds the first Resource matching the given pattern, or nil if none found.

It looks for files in the assets file system.

See Match for a more complete explanation about the rules used.

func (*Namespace) Minify

Minify minifies the given Resource using the MediaType to pick the correct minifier.

func (*Namespace) ToCSS

func (ns *Namespace) ToCSS(args ...any) (resources.Resource, error)

ToCSS converts the given Resource to CSS. You can optional provide an Options object as second argument. As an option, you can e.g. specify e.g. the target path (string) for the converted CSS resource.

type Resource

type Resource interface {
	GetResource(pathname string) (resources.Resource, error)
	GetMatch(pattern string) (resources.Resource, error)
	Copy(r resources.Resource, targetPath string) (resources.Resource, error)

	Minify(r resources.Resource) (resources.Resource, error)

	ExecuteAsTemplate(ctx context.Context, res resources.Resource, targetPath string, data any) (resources.Resource, error)

	Fingerprint(res resources.Resource, algo string) (resources.Resource, error)

	ToCSS(res resources.Resource, args map[string]any) (resources.Resource, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL