diff options
author | Bjørn Erik Pedersen <[email protected]> | 2018-08-05 11:13:49 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2018-08-06 19:58:41 +0200 |
commit | 789ef8c639e4621abd36da530bcb5942ac9297da (patch) | |
tree | f225fc3663affc49805f1d309b77b096d40fc8f6 /hugolib/alias.go | |
parent | 71931b30b1813b146aaa60f5cdab16c0f9ebebdb (diff) | |
download | hugo-789ef8c639e4621abd36da530bcb5942ac9297da.tar.gz hugo-789ef8c639e4621abd36da530bcb5942ac9297da.zip |
Add support for minification of final output
Hugo Pipes added minification support for resources fetched via ´resources.Get` and similar.
This also adds support for minification of the final output for supported output formats: HTML, XML, SVG, CSS, JavaScript, JSON.
To enable, run Hugo with the `--minify` flag:
```bash
hugo --minify
```
This commit is also a major spring cleaning of the `transform` package to allow the new minification step fit into that processing chain.
Fixes #1251
Diffstat (limited to 'hugolib/alias.go')
-rw-r--r-- | hugolib/alias.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/hugolib/alias.go b/hugolib/alias.go index 3b053130e..b2b296143 100644 --- a/hugolib/alias.go +++ b/hugolib/alias.go @@ -22,6 +22,8 @@ import ( "runtime" "strings" + "github.com/gohugoio/hugo/output" + "github.com/gohugoio/hugo/publisher" "github.com/gohugoio/hugo/tpl" jww "github.com/spf13/jwalterweatherman" @@ -89,11 +91,11 @@ func (a aliasHandler) renderAlias(isXHTML bool, permalink string, page *Page) (i return buffer, nil } -func (s *Site) writeDestAlias(path, permalink string, p *Page) (err error) { - return s.publishDestAlias(false, path, permalink, p) +func (s *Site) writeDestAlias(path, permalink string, outputFormat output.Format, p *Page) (err error) { + return s.publishDestAlias(false, path, permalink, outputFormat, p) } -func (s *Site) publishDestAlias(allowRoot bool, path, permalink string, p *Page) (err error) { +func (s *Site) publishDestAlias(allowRoot bool, path, permalink string, outputFormat output.Format, p *Page) (err error) { handler := newAliasHandler(s.Tmpl, s.Log, allowRoot) isXHTML := strings.HasSuffix(path, ".xhtml") @@ -110,7 +112,14 @@ func (s *Site) publishDestAlias(allowRoot bool, path, permalink string, p *Page) return err } - return s.publish(&s.PathSpec.ProcessingStats.Aliases, targetPath, aliasContent) + pd := publisher.Descriptor{ + Src: aliasContent, + TargetPath: targetPath, + StatCounter: &s.PathSpec.ProcessingStats.Aliases, + OutputFormat: outputFormat, + } + + return s.publisher.Publish(pd) } |