Documentation ¶
Index ¶
- Constants
- func AssignMetadata(metadata []map[string]interface{}, resources ...Resource) error
- func ResourceKeyPartition(filename string) string
- type Cloner
- type ContentResource
- 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) 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() (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) Title() string
- func (i *Image) Width() int
- func (i *Image) WithNewBase(base string) Resource
- type Imaging
- type OpenReadSeekCloser
- type ReadSeekCloser
- type ReadSeekCloserResource
- type ReadSeeker
- type ReadSeekerNoOpCloser
- type Resource
- type ResourceCache
- type ResourceSourceDescriptor
- type ResourceTransformation
- type ResourceTransformationCtx
- type ResourceTransformationKey
- type Resources
- type ResourcesLanguageMerger
- type Source
- 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, error)
- func (r *Spec) NewForFs(sourceFs afero.Fs, fd ResourceSourceDescriptor) (Resource, error)
- func (s *Spec) Transform(r Resource, t ResourceTransformation) (Resource, error)
Constants ¶
const ( CACHE_CLEAR_ALL = "clear_all" CACHE_OTHER = "other" )
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
func ResourceKeyPartition ¶ added in v0.45.1
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 Cloner ¶
Cloner is an internal template and not meant for use in the templates. It may change without notice.
type ContentResource ¶ added in v0.45.1
type ContentResource interface { Resource // 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) }
ContentResource represents a Resource that provides a way to get to its content. Most Resource types in Hugo implements this interface, including Page. This should be used with care, as it will read the file content into memory, but it should be cached as effectively as possible by the implementation.
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
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 ¶ added in v0.45.1
func (l Image) ReadSeekCloser() (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) 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 OpenReadSeekCloser ¶ added in v0.45.1
type OpenReadSeekCloser func() (ReadSeekCloser, error)
OpenReadSeekeCloser allows setting some other way (than reading from a filesystem) to open or create a ReadSeekCloser.
type ReadSeekCloser ¶ added in v0.45.1
type ReadSeekCloser interface { ReadSeeker io.Closer }
ReadSeekCloser is implemented by afero.File. We use this as the common type for content in Resource objects, even for strings.
type ReadSeekCloserResource ¶ added in v0.45.1
type ReadSeekCloserResource interface { Resource ReadSeekCloser() (ReadSeekCloser, error) }
ReadSeekCloserResource is a Resource that supports loading its content.
type ReadSeeker ¶ added in v0.45.1
ReadSeeker wraps io.Reader and io.Seeker.
type ReadSeekerNoOpCloser ¶ added in v0.45.1
type ReadSeekerNoOpCloser struct {
ReadSeeker
}
ReadSeekerNoOpCloser implements ReadSeekCloser by doing nothing in Close.
func NewReadSeekerNoOpCloser ¶ added in v0.45.1
func NewReadSeekerNoOpCloser(r ReadSeeker) ReadSeekerNoOpCloser
NewReadSeekerNoOpCloser creates a new ReadSeekerNoOpCloser with the given ReadSeeker.
func NewReadSeekerNoOpCloserFromString ¶ added in v0.45.1
func NewReadSeekerNoOpCloserFromString(content string) ReadSeekerNoOpCloser
NewReadSeekerNoOpCloserFromString uses strings.NewReader to create a new ReadSeekerNoOpCloser from the given string.
func (ReadSeekerNoOpCloser) Close ¶ added in v0.45.1
func (r ReadSeekerNoOpCloser) Close() error
Close does nothing.
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 // MediaType is this resource's MIME type. MediaType() media.Type // 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 // Resource specific data set by Hugo. // One example would be.Data.Digest for fingerprinted resources. Data() interface{} // Params set in front matter for this resource. Params() map[string]interface{} }
Resource represents a linkable resource, i.e. a content page, image etc.
type ResourceCache ¶ added in v0.45.1
func (*ResourceCache) Contains ¶ added in v0.45.1
func (c *ResourceCache) Contains(key string) bool
func (*ResourceCache) DeletePartitions ¶ added in v0.45.1
func (c *ResourceCache) DeletePartitions(partitions ...string)
func (*ResourceCache) GetOrCreate ¶ added in v0.45.1
type ResourceSourceDescriptor ¶ added in v0.45.1
type ResourceSourceDescriptor struct { // TargetPathBuilder is a callback to create target paths's relative to its owner. TargetPathBuilder func(base string) string // Need one of these to load the resource content. SourceFile source.File OpenReadSeekCloser 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 path prepeneded to the permalink. // Typically the language code if this resource should be published to its sub-folder. URLBase 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 ¶ added in v0.45.1
func (r ResourceSourceDescriptor) Filename() string
type ResourceTransformation ¶ added in v0.45.1
type ResourceTransformation interface { Key() ResourceTransformationKey Transform(ctx *ResourceTransformationCtx) error }
ResourceTransformation is the interface that a resource transformation step needs to implement.
type ResourceTransformationCtx ¶ added in v0.45.1
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 ¶ added in v0.45.1
func (ctx *ResourceTransformationCtx) AddOutPathIdentifier(identifier string)
AddOutPathIdentifier transforming InPath to OutPath adding an identifier, eg '.min' before any extension.
func (*ResourceTransformationCtx) PublishSourceMap ¶ added in v0.45.1
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 ¶ added in v0.45.1
func (ctx *ResourceTransformationCtx) ReplaceOutPathExtension(newExt string)
ReplaceOutPathExtension transforming InPath to OutPath replacing the file extension, e.g. ".scss"
type ResourceTransformationKey ¶ added in v0.45.1
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 ¶ added in v0.45.1
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 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) 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 ¶
type Source interface {
Publish() error
}
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 MediaTypes media.Types OutputFormats output.Formats Logger *jww.Notepad TextTemplates tpl.TemplateParseFinder ResourceCache *ResourceCache GenImagePath string GenAssetsPath string // contains filtered or unexported fields }
func (*Spec) CacheStats ¶
func (*Spec) ClearCaches ¶ added in v0.45.1
func (r *Spec) ClearCaches()
func (*Spec) DeleteCacheByPrefix ¶
func (*Spec) IsInImageCache ¶ added in v0.45.1
TODO(bep) unify
func (*Spec) New ¶ added in v0.45.1
func (r *Spec) New(fd ResourceSourceDescriptor) (Resource, error)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package bundler contains functions for concatenation etc.
|
Package bundler contains functions for concatenation etc. |
Package create contains functions for to create Resource objects.
|
Package create contains functions for to create Resource objects. |
Package templates contains functions for template processing of Resource objects.
|
Package templates contains functions for template processing of Resource objects. |
tocss
|
|