Documentation ¶
Index ¶
- Constants
- func AssignMetadata(metadata []map[string]interface{}, resources ...resource.Resource) error
- func ResourceKeyPartition(filename string) string
- type Image
- func (l Image) Content() (interface{}, error)
- func (l Image) Data() interface{}
- func (i *Image) Fill(spec string) (*Image, error)
- func (i *Image) Fit(spec string) (*Image, error)
- func (i *Image) Height() int
- func (l Image) Key() string
- func (l Image) MediaType() media.Type
- 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) ReadSeekCloser() (hugio.ReadSeekCloser, 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) TargetPath() string
- func (l Image) Title() string
- func (i *Image) Width() int
- func (i *Image) WithNewBase(base string) resource.Resource
- type Imaging
- type ResourceCache
- type ResourceSourceDescriptor
- type ResourceTransformation
- type ResourceTransformationCtx
- type ResourceTransformationKey
- type Spec
- func (r *Spec) CacheStats() string
- func (r *Spec) ClearCaches()
- func (r *Spec) DeleteCacheByPrefix(prefix string)
- func (r *Spec) IsInImageCache(key string) bool
- func (r *Spec) New(fd ResourceSourceDescriptor) (resource.Resource, error)
- func (r *Spec) NewForFs(sourceFs afero.Fs, fd ResourceSourceDescriptor) (resource.Resource, error)
- func (s *Spec) Transform(r resource.Resource, t ResourceTransformation) (resource.Resource, error)
Constants ¶
const ( CACHE_CLEAR_ALL = "clear_all" CACHE_OTHER = "other" )
Variables ¶
This section is empty.
Functions ¶
func AssignMetadata ¶
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
func ResourceKeyPartition ¶
ResourceKeyPartition returns a partition name to allow for more fine grained cache flushes. It will return the file extension without the leading ".". If no extension, it will return "other".
Types ¶
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image represents an image resource.
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) ReadSeekCloser ¶
func (l Image) ReadSeekCloser() (hugio.ReadSeekCloser, error)
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) TargetPath ¶ added in v0.55.0
func (l Image) TargetPath() string
Path is stored with Unix style slashes.
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 ResourceCache ¶
func (*ResourceCache) Contains ¶
func (c *ResourceCache) Contains(key string) bool
func (*ResourceCache) DeletePartitions ¶
func (c *ResourceCache) DeletePartitions(partitions ...string)
func (*ResourceCache) GetOrCreate ¶
type ResourceSourceDescriptor ¶
type ResourceSourceDescriptor struct { // TargetPaths is a callback to fetch paths's relative to its owner. TargetPaths func() page.TargetPaths // Need one of these to load the resource content. SourceFile source.File OpenReadSeekCloser resource.OpenReadSeekCloser // If OpenReadSeekerCloser is not set, we use this to open the file. SourceFilename string // The relative target filename without any language code. RelTargetFilename string // Any base paths prepended to the target path. This will also typically be the // language code, but setting it here means that it should not have any effect on // the permalink. // This may be several values. In multihost mode we may publish the same resources to // multiple targets. TargetBasePaths []string // Delay publishing until either Permalink or RelPermalink is called. Maybe never. LazyPublish bool }
func (ResourceSourceDescriptor) Filename ¶
func (r ResourceSourceDescriptor) Filename() string
type ResourceTransformation ¶
type ResourceTransformation interface { Key() ResourceTransformationKey Transform(ctx *ResourceTransformationCtx) error }
ResourceTransformation is the interface that a resource transformation step needs to implement.
type ResourceTransformationCtx ¶
type ResourceTransformationCtx struct { // The content to transform. From io.Reader // The target of content transformation. // The current implementation requires that r is written to w // even if no transformation is performed. To io.Writer // This is the relative path to the original source. Unix styled slashes. SourcePath string // This is the relative target path to the resource. Unix styled slashes. InPath string // The relative target path to the transformed resource. Unix styled slashes. OutPath string // The input media type InMediaType media.Type // The media type of the transformed resource. OutMediaType media.Type // Data data can be set on the transformed Resource. Not that this need // to be simple types, as it needs to be serialized to JSON and back. Data map[string]interface{} // This is used to publis additional artifacts, e.g. source maps. // We may improve this. OpenResourcePublisher func(relTargetPath string) (io.WriteCloser, error) }
func (*ResourceTransformationCtx) AddOutPathIdentifier ¶
func (ctx *ResourceTransformationCtx) AddOutPathIdentifier(identifier string)
AddOutPathIdentifier transforming InPath to OutPath adding an identifier, eg '.min' before any extension.
func (*ResourceTransformationCtx) PublishSourceMap ¶
func (ctx *ResourceTransformationCtx) PublishSourceMap(content string) error
PublishSourceMap writes the content to the target folder of the main resource with the ".map" extension added.
func (*ResourceTransformationCtx) ReplaceOutPathExtension ¶
func (ctx *ResourceTransformationCtx) ReplaceOutPathExtension(newExt string)
ReplaceOutPathExtension transforming InPath to OutPath replacing the file extension, e.g. ".scss"
type ResourceTransformationKey ¶
type ResourceTransformationKey struct {
// contains filtered or unexported fields
}
ResourceTransformationKey are provided by the different transformation implementations. It identifies the transformation (name) and its configuration (elements). We combine this in a chain with the rest of the transformations with the target filename and a content hash of the origin to use as cache key.
func NewResourceTransformationKey ¶
func NewResourceTransformationKey(name string, elements ...interface{}) ResourceTransformationKey
NewResourceTransformationKey creates a new ResourceTransformationKey from the transformation name and elements. We will create a 64 bit FNV hash from the elements, which when combined with the other key elements should be unique for all practical applications.
type Spec ¶
type Spec struct { *helpers.PathSpec MediaTypes media.Types OutputFormats output.Formats Logger *loggers.Logger TextTemplates tpl.TemplateParseFinder Permalinks page.PermalinkExpander ResourceCache *ResourceCache FileCaches filecache.Caches // contains filtered or unexported fields }
func (*Spec) CacheStats ¶
func (*Spec) ClearCaches ¶
func (r *Spec) ClearCaches()
func (*Spec) DeleteCacheByPrefix ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package page contains the core interfaces and types for the Page resource, a core component in Hugo.
|
Package page contains the core interfaces and types for the Page resource, a core component in Hugo. |
resource_factories
|
|
bundler
Package bundler contains functions for concatenation etc.
|
Package bundler contains functions for concatenation etc. |
create
Package create contains functions for to create Resource objects.
|
Package create contains functions for to create Resource objects. |
resource_transformers
|
|
templates
Package templates contains functions for template processing of Resource objects.
|
Package templates contains functions for template processing of Resource objects. |