Documentation ¶
Index ¶
- Constants
- func AssignMetadata(metadata []map[string]interface{}, resources ...Resource) error
- type Cloner
- type Image
- func (l Image) AbsSourceFilename() string
- func (l Image) Content() (interface{}, error)
- func (i *Image) Fill(spec string) (*Image, error)
- func (i *Image) Fit(spec string) (*Image, error)
- func (i *Image) Height() int
- func (l Image) Name() string
- func (l Image) Params() map[string]interface{}
- func (l Image) Permalink() string
- func (l Image) Publish() error
- func (l Image) RelPermalink() string
- func (i *Image) Resize(spec string) (*Image, error)
- func (l Image) ResourceType() string
- func (l Image) String() string
- func (l Image) Title() string
- func (i *Image) Width() int
- func (i *Image) WithNewBase(base string) Resource
- type Imaging
- type Resource
- type Resources
- func (r Resources) ByPrefix(prefix string) Resources
- func (r Resources) ByType(tp string) Resources
- func (r Resources) GetByPrefix(prefix string) Resource
- func (r Resources) GetMatch(pattern string) Resource
- func (r Resources) Match(pattern string) Resources
- func (r1 Resources) MergeByLanguage(r2 Resources) Resources
- func (r1 Resources) MergeByLanguageInterface(in interface{}) (interface{}, error)
- type ResourcesLanguageMerger
- type Source
- type Spec
- func (r *Spec) CacheStats() string
- func (r *Spec) DeleteCacheByPrefix(prefix string)
- func (r *Spec) IsInCache(key string) bool
- func (r *Spec) NewResourceFromFile(targetPathBuilder func(base string) string, file source.File, ...) (Resource, error)
- func (r *Spec) NewResourceFromFilename(targetPathBuilder func(base string) string, ...) (Resource, error)
Constants ¶
const DefaultResourceType = "unknown"
Variables ¶
This section is empty.
Functions ¶
func AssignMetadata ¶ added in v0.36.1
AssignMetadata assigns the given metadata to those resources that supports updates and matching by wildcard given in `src` using `filepath.Match` with lower cased values. This assignment is additive, but the most specific match needs to be first. The `name` and `title` metadata field support shell-matched collection it got a match in. See https://golang.org/pkg/path/#Match
Types ¶
type Cloner ¶
Cloner is an internal template and not meant for use in the templates. It may change without notice.
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
func (Image) AbsSourceFilename ¶
func (l Image) AbsSourceFilename() string
func (*Image) Fill ¶
Fill scales the image to the smallest possible size that will cover the specified dimensions, crops the resized image to the specified dimensions using the given anchor point. Space delimited config: 200x300 TopLeft
func (*Image) Fit ¶
Fit scales down the image using the specified resample filter to fit the specified maximum width and height.
func (Image) RelPermalink ¶
func (l Image) RelPermalink() string
func (*Image) Resize ¶
Resize resizes the image to the specified width and height using the specified resampling filter and returns the transformed image. If one of width or height is 0, the image aspect ratio is preserved.
func (Image) ResourceType ¶
func (l Image) ResourceType() string
func (*Image) WithNewBase ¶
Implement the Cloner interface.
type Imaging ¶
type Imaging struct { // Default image quality setting (1-100). Only used for JPEG images. Quality int // Resample filter used. See https://github.com/disintegration/imaging ResampleFilter string // The anchor used in Fill. Default is "smart", i.e. Smart Crop. Anchor string }
Imaging contains default image processing configuration. This will be fetched from site (or language) config.
type Resource ¶
type Resource interface { // Permalink represents the absolute link to this resource. Permalink() string // RelPermalink represents the host relative link to this resource. RelPermalink() string // ResourceType is the resource type. For most file types, this is the main // part of the MIME type, e.g. "image", "application", "text" etc. // For content pages, this value is "page". ResourceType() string // Name is the logical name of this resource. This can be set in the front matter // metadata for this resource. If not set, Hugo will assign a value. // This will in most cases be the base filename. // So, for the image "/some/path/sunset.jpg" this will be "sunset.jpg". // The value returned by this method will be used in the GetByPrefix and ByPrefix methods // on Resources. Name() string // Title returns the title if set in front matter. For content pages, this will be the expected value. Title() string // Params set in front matter for this resource. Params() map[string]interface{} // Content returns this resource's content. It will be equivalent to reading the content // that RelPermalink points to in the published folder. // The return type will be contextual, and should be what you would expect: // * Page: template.HTML // * JSON: String // * Etc. Content() (interface{}, error) }
Resource represents a linkable resource, i.e. a content page, image etc.
type Resources ¶
type Resources []Resource
Resources represents a slice of resources, which can be a mix of different types. I.e. both pages and images etc.
func (Resources) ByPrefix ¶ added in v0.36.1
ByPrefix gets all resources matching the given base filename prefix, e.g "logo" will match logo.png.
func (Resources) GetByPrefix ¶
GetByPrefix gets the first resource matching the given filename prefix, e.g "logo" will match logo.png. It returns nil of none found. In potential ambiguous situations, combine it with ByType.
func (Resources) GetMatch ¶ added in v0.36.1
GetMatch finds the first Resource matching the given pattern, or nil if none found. See Match for a more complete explanation about the rules used.
func (Resources) Match ¶ added in v0.36.1
Match gets all resources matching the given base filename prefix, e.g "*.png" will match all png files. The "*" does not match path delimiters (/), so if you organize your resources in sub-folders, you need to be explicit about it, e.g.: "images/*.png". To match any PNG image anywhere in the bundle you can do "**.png", and to match all PNG images below the images folder, use "images/**.jpg". The matching is case insensitive. Match matches by using the value of Resource.Name, which, by default, is a filename with path relative to the bundle root with Unix style slashes (/) and no leading slash, e.g. "images/logo.png". See https://github.com/gobwas/glob for the full rules set.
func (Resources) MergeByLanguage ¶ added in v0.40.1
MergeByLanguage adds missing translations in r1 from r2.
func (Resources) MergeByLanguageInterface ¶ added in v0.40.1
MergeByLanguageInterface is the generic version of MergeByLanguage. It is here just so it can be called from the tpl package.
type ResourcesLanguageMerger ¶ added in v0.40.1
type Source ¶
Source is an internal template and not meant for use in the templates. It may change without notice.
type Spec ¶
type Spec struct { *helpers.PathSpec GenImagePath string // contains filtered or unexported fields }