Documentation ¶
Index ¶
- Constants
- Variables
- func ClassifyType(t string) string
- func ContentReadSeekerCloser(r resources.Resource) (pio.ReadSeekCloser, error)
- func CreateVarsStyleSheet(vars map[string]any) string
- func DefaultExtension(f resources.ImageFormat) string
- func ImageFormatFromExt(ext string) (resources.ImageFormat, bool)
- func ImageFormatFromMediaSubType(sub string) (resources.ImageFormat, bool)
- func IsDartSassV2() bool
- func IsOpaque(img image.Image) bool
- func MediaType(f resources.ImageFormat) media.Type
- func RequiresDefaultQuality(f resources.ImageFormat) bool
- func SetDartSassBinaryName()
- func SupportsTransparency(f resources.ImageFormat) bool
- func ToFilters(in any) []gift.Filter
- func UnwrapFilter(in gift.Filter) gift.Filter
- type DartSassOptions
- type FileCaches
- func (f FileCaches) AssetsCache() *filecache.Cache
- func (f FileCaches) Get(name string) *filecache.Cache
- func (f FileCaches) GetCSVCache() *filecache.Cache
- func (f FileCaches) GetJSONCache() *filecache.Cache
- func (f FileCaches) GetResourceCache() *filecache.Cache
- func (f FileCaches) ImageCache() *filecache.Cache
- type Filter
- type Giphy
- type Image
- type ImageConfig
- type ImageFilterFromOrientationProvider
- type ImageProcessSpecProvider
- type ImageProcessor
- func (p *ImageProcessor) ApplyFiltersFromConfig(src image.Image, conf ImageConfig) (image.Image, error)
- func (p *ImageProcessor) DecodeExif(r io.Reader) (*exif.ExifInfo, error)
- func (p *ImageProcessor) Filter(src image.Image, filters ...gift.Filter) (image.Image, error)
- func (p *ImageProcessor) FiltersFromConfig(src image.Image, conf ImageConfig) ([]gift.Filter, error)
- type ImageSource
- type ImportResolver
- type ImportResolverV1
- type PublishOnce
- type ResTransCtxBuilder
- func (b *ResTransCtxBuilder) Build() *ResourceTransformationCtx
- func (b *ResTransCtxBuilder) WithMediaType(m media.Type) *ResTransCtxBuilder
- func (b *ResTransCtxBuilder) WithSource(src pio.ReadSeekCloser) *ResTransCtxBuilder
- func (b *ResTransCtxBuilder) WithTargetPath(targetPath string) *ResTransCtxBuilder
- type ResourceHash
- type ResourceMetadata
- type ResourcePaths
- func (d ResourcePaths) FromTargetPath(targetPath string) ResourcePaths
- func (d ResourcePaths) Path() string
- func (d ResourcePaths) PathBaseDirLink() string
- func (d ResourcePaths) PathBaseDirTarget() string
- func (d ResourcePaths) PathDir() string
- func (d ResourcePaths) PathFile() string
- func (d ResourcePaths) PathTargetBasePaths() []string
- func (d ResourcePaths) TargetFilenames() []string
- func (d ResourcePaths) TargetLink() string
- func (d ResourcePaths) TargetPath() string
- func (d ResourcePaths) TargetPaths() []string
- type ResourceTransformationCtx
- func (ctx *ResourceTransformationCtx) AddOutPathIdentifier(identifier string)
- func (ctx *ResourceTransformationCtx) Close()
- func (ctx *ResourceTransformationCtx) ReplaceOutPathExtension(newExt string)
- func (ctx *ResourceTransformationCtx) SourcePath() string
- func (ctx *ResourceTransformationCtx) UpdateBuffer()
- func (ctx *ResourceTransformationCtx) UpdateSource()
- type ResourceTransformationKey
- type TransformationSource
- type TransformationTarget
Constants ¶
const ( ActionResize = "resize" ActionCrop = "crop" ActionFit = "fit" ActionFill = "fill" )
const (
HugoVarsNamespace = "hugo:vars"
)
Variables ¶
var DartSassBinaryName string
Functions ¶
func ClassifyType ¶
func ContentReadSeekerCloser ¶
func ContentReadSeekerCloser(r resources.Resource) (pio.ReadSeekCloser, error)
ContentReadSeekerCloser returns a ReadSeekerCloser if possible for a given Resource.
func CreateVarsStyleSheet ¶
func DefaultExtension ¶
func DefaultExtension(f resources.ImageFormat) string
DefaultExtension returns the default file extension of this format, starting with a dot. For example: .jpg for resources.JPEG
func ImageFormatFromExt ¶
func ImageFormatFromExt(ext string) (resources.ImageFormat, bool)
func ImageFormatFromMediaSubType ¶
func ImageFormatFromMediaSubType(sub string) (resources.ImageFormat, bool)
func IsDartSassV2 ¶
func IsDartSassV2() bool
func IsOpaque ¶
IsOpaque returns false if the images has alpha channel and there is at least 1 pixel that is not (fully) opaque.
func MediaType ¶
func MediaType(f resources.ImageFormat) media.Type
MediaType returns the media type of this images, e.g. images/jpeg for resources.JPEG
func RequiresDefaultQuality ¶
func RequiresDefaultQuality(f resources.ImageFormat) bool
RequiresDefaultQuality returns if the default quality needs to be applied to images of this format.
func SetDartSassBinaryName ¶
func SetDartSassBinaryName()
func SupportsTransparency ¶
func SupportsTransparency(f resources.ImageFormat) bool
SupportsTransparency reports whether it supports transparency in any form.
Types ¶
type DartSassOptions ¶
type DartSassOptions struct { // Hugo, will by default, just replace the extension of the source // to .css, e.g. "scss/main.scss" becomes "scss/main.css". You can // control this by setting this, e.g. "styles/main.css" will create // a Resource with that as a base for RelPermalink etc. TargetPath string // Hugo automatically adds the entry directories (where the main.scss lives) // for project and themes to the list of include paths sent to LibSASS. // Any paths set in this setting will be appended. Note that these will be // treated as relative to the working dir, i.e. no include paths outside the // project/themes. IncludePaths []string // Default is nested. // One of nested, expanded, compact, compressed. OutputStyle string // When enabled, Hugo will generate a source map. EnableSourceMap bool // If enabled, sources will be embedded in the generated source map. SourceMapIncludeSources bool // Vars will be available in 'hugo:vars', e.g: // @use "hugo:vars"; // $color: vars.$color; Vars map[string]any }
func DecodeDartSassOptions ¶
func DecodeDartSassOptions(m map[string]any) (opts DartSassOptions, err error)
type FileCaches ¶
FileCaches is a named set of caches.
func (FileCaches) AssetsCache ¶
func (f FileCaches) AssetsCache() *filecache.Cache
AssetsCache gets the file cache for assets (processed resources, SCSS etc.).
func (FileCaches) Get ¶
func (f FileCaches) Get(name string) *filecache.Cache
Get gets a named cache, nil if none found.
func (FileCaches) GetCSVCache ¶
func (f FileCaches) GetCSVCache() *filecache.Cache
GetCSVCache gets the file cache for getCSV.
func (FileCaches) GetJSONCache ¶
func (f FileCaches) GetJSONCache() *filecache.Cache
GetJSONCache gets the file cache for getJSON.
func (FileCaches) GetResourceCache ¶
func (f FileCaches) GetResourceCache() *filecache.Cache
GetResourceCache gets the file cache for remote resources.
func (FileCaches) ImageCache ¶
func (f FileCaches) ImageCache() *filecache.Cache
type Image ¶
type Image struct { ImageFormat resources.ImageFormat Spec pio.ReadSeekCloserProvider // contains filtered or unexported fields }
func NewImage ¶
func NewImage(f resources.ImageFormat, img image.Image, s pio.ReadSeekCloserProvider) *Image
func (*Image) InitConfig ¶
InitConfig reads the images config from the given reader.
type ImageConfig ¶
type ImageConfig struct { // This defines the output format of the output images. It defaults to the source format. TargetFormat resources.ImageFormat Action string // If set, this will be used as the key in filenames etc. Key string // Quality ranges from 1 to 100 inclusive, higher is better. // This is only relevant for JPEG and WEBP images. // Default is 75. Quality int // Rotate rotates an images by the given angle counter-clockwise. // The rotation will be performed first. Rotate int // Used to fill any transparency. // When set in site config, it's used when converting to a format that does // not support transparency. // When set per images operation, it's used even for formats that does support // transparency. BgColor color.Color BgColorStr string // Hint about what type of picture this is. Used to optimize encoding // when target is set to webp. Hint webpoptions.EncodingPreset Width int Height int Filter gift.Resampling FilterStr string Anchor gift.Anchor AnchorStr string // contains filtered or unexported fields }
ImageConfig holds configuration to create a new images from an existing one, resize etc.
func DecodeImageConfig ¶
func DecodeImageConfig(action string, options []string, defaults resources.ImageConfig, sourceFormat resources.ImageFormat) (ImageConfig, error)
func GetDefaultImageConfig ¶
func GetDefaultImageConfig(action string, defaults resources.ImageConfig) ImageConfig
func (ImageConfig) GetKey ¶
func (i ImageConfig) GetKey(format resources.ImageFormat) string
type ImageProcessSpecProvider ¶
type ImageProcessSpecProvider interface {
ImageProcessSpec() string
}
type ImageProcessor ¶
func (*ImageProcessor) ApplyFiltersFromConfig ¶
func (p *ImageProcessor) ApplyFiltersFromConfig(src image.Image, conf ImageConfig) (image.Image, error)
func (*ImageProcessor) DecodeExif ¶
func (*ImageProcessor) FiltersFromConfig ¶
func (p *ImageProcessor) FiltersFromConfig(src image.Image, conf ImageConfig) ([]gift.Filter, error)
type ImageSource ¶
ImageSource identifies and decodes an images.
type ImportResolver ¶
type ImportResolver struct { BaseDir string FsService resources.Fs DependencyManager identity.Manager VarsStylesheet godartsass.Import }
func (ImportResolver) CanonicalizeURL ¶
func (t ImportResolver) CanonicalizeURL(url string) (string, error)
func (ImportResolver) Load ¶
func (t ImportResolver) Load(url string) (godartsass.Import, error)
type ImportResolverV1 ¶
type ImportResolverV1 struct {
godartsass.ImportResolver
}
func (ImportResolverV1) Load ¶
func (t ImportResolverV1) Load(url string) (godartsassv1.Import, error)
type PublishOnce ¶
type ResTransCtxBuilder ¶
type ResTransCtxBuilder struct { DepSvc resources.DependenceSvc PubSvc resources.PublishSvc // contains filtered or unexported fields }
func NewResourceTransformationCtxBuilder ¶
func NewResourceTransformationCtxBuilder(d resources.DependenceSvc, p resources.PublishSvc) *ResTransCtxBuilder
func (*ResTransCtxBuilder) Build ¶
func (b *ResTransCtxBuilder) Build() *ResourceTransformationCtx
func (*ResTransCtxBuilder) WithMediaType ¶
func (b *ResTransCtxBuilder) WithMediaType(m media.Type) *ResTransCtxBuilder
func (*ResTransCtxBuilder) WithSource ¶
func (b *ResTransCtxBuilder) WithSource(src pio.ReadSeekCloser) *ResTransCtxBuilder
func (*ResTransCtxBuilder) WithTargetPath ¶
func (b *ResTransCtxBuilder) WithTargetPath(targetPath string) *ResTransCtxBuilder
type ResourceHash ¶
func (*ResourceHash) Setup ¶
func (r *ResourceHash) Setup(l io.ReadSeekCloserProvider) error
type ResourceMetadata ¶
type ResourceMetadata struct { Target string `json:"Target"` MediaTypeV string `json:"MediaType"` MetaData map[string]any `json:"Data"` }
func (ResourceMetadata) Marshal ¶
func (r ResourceMetadata) Marshal() ([]byte, error)
func (ResourceMetadata) Unmarshal ¶
func (r ResourceMetadata) Unmarshal(data []byte) (ResourceMetadata, error)
type ResourcePaths ¶
type ResourcePaths struct { // This is the directory component for the target file or link. Dir string // Any base directory for the target file. Will be prepended to Dir. BaseDirTarget string // This is the directory component for the link will be prepended to Dir. BaseDirLink string // Set when publishing in a multihost setup. TargetBasePaths []string // This is the File component, e.g. "data.json". File string }
ResourcePaths holds path information for a resource. All directories in here have Unix-style slashes, with leading slash, but no trailing slash. Empty directories are represented with an empty string.
func NewResourcePaths ¶
func NewResourcePaths(targetPath string) ResourcePaths
func (ResourcePaths) FromTargetPath ¶
func (d ResourcePaths) FromTargetPath(targetPath string) ResourcePaths
func (ResourcePaths) Path ¶
func (d ResourcePaths) Path() string
func (ResourcePaths) PathBaseDirLink ¶
func (d ResourcePaths) PathBaseDirLink() string
func (ResourcePaths) PathBaseDirTarget ¶
func (d ResourcePaths) PathBaseDirTarget() string
func (ResourcePaths) PathDir ¶
func (d ResourcePaths) PathDir() string
func (ResourcePaths) PathFile ¶
func (d ResourcePaths) PathFile() string
func (ResourcePaths) PathTargetBasePaths ¶
func (d ResourcePaths) PathTargetBasePaths() []string
func (ResourcePaths) TargetFilenames ¶
func (d ResourcePaths) TargetFilenames() []string
func (ResourcePaths) TargetLink ¶
func (d ResourcePaths) TargetLink() string
func (ResourcePaths) TargetPath ¶
func (d ResourcePaths) TargetPath() string
func (ResourcePaths) TargetPaths ¶
func (d ResourcePaths) TargetPaths() []string
type ResourceTransformationCtx ¶
type ResourceTransformationCtx struct { // The context that started the transformation. Ctx context.Context DepSvc resources.DependenceSvc PubSvc resources.PublishSvc Source *TransformationSource Target *TransformationTarget // 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]any // contains filtered or unexported fields }
func (*ResourceTransformationCtx) AddOutPathIdentifier ¶
func (ctx *ResourceTransformationCtx) AddOutPathIdentifier(identifier string)
AddOutPathIdentifier transforming InPath to OutPath adding an identifier, eg '.min' before any extension.
func (*ResourceTransformationCtx) Close ¶
func (ctx *ResourceTransformationCtx) Close()
func (*ResourceTransformationCtx) ReplaceOutPathExtension ¶
func (ctx *ResourceTransformationCtx) ReplaceOutPathExtension(newExt string)
ReplaceOutPathExtension transforming InPath to OutPath replacing the file extension, e.g. ".scss"
func (*ResourceTransformationCtx) SourcePath ¶
func (ctx *ResourceTransformationCtx) SourcePath() string
func (*ResourceTransformationCtx) UpdateBuffer ¶
func (ctx *ResourceTransformationCtx) UpdateBuffer()
func (*ResourceTransformationCtx) UpdateSource ¶
func (ctx *ResourceTransformationCtx) UpdateSource()
type ResourceTransformationKey ¶
type ResourceTransformationKey struct { Name string // 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 ...any) 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.
func (ResourceTransformationKey) Value ¶
func (k ResourceTransformationKey) Value() string
Value returns the Key as a string. Do not change this without good reasons.
type TransformationSource ¶
type TransformationTarget ¶
type TransformationTarget struct { // The target of Content transformation. // The current implementation requires that r is written to w // even if no transformation is performed. To io.Writer // The relative target path to the transformed resource. Unix styled slashes. OutPath string // The media type of the transformed resource. OutMediaType media.Type }
Source Files ¶
- classify.go
- dartsass.go
- filecache.go
- giphy.go
- hash.go
- image.go
- imageconfig.go
- imagefilter.go
- imageformat.go
- imageorient.go
- imageprocess.go
- imageprocessor.go
- imageresizer.go
- imageservice.go
- importresolver.go
- publishonce.go
- resourcemetadata.go
- resourcepaths.go
- transformation.go
- transformationcontext.go
- transformationctxbuilder.go