aboutsummaryrefslogtreecommitdiffhomepage
path: root/deps
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2022-09-14 11:58:45 +0200
committerBjørn Erik Pedersen <[email protected]>2022-09-14 19:09:20 +0200
commit74daca6b3050d96cd3a08b13f45de24edb450163 (patch)
treed740f7e7174c4685dae8cb262a790300b005be76 /deps
parent1fd4c562afd467f246c632e9f3fed0a1f350d8dc (diff)
downloadhugo-74daca6b3050d96cd3a08b13f45de24edb450163.tar.gz
hugo-74daca6b3050d96cd3a08b13f45de24edb450163.zip
Support PostProcess for all file types
Not just HTML. Fixes #10269
Diffstat (limited to 'deps')
-rw-r--r--deps/deps.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/deps/deps.go b/deps/deps.go
index ece420302..e1cbfce06 100644
--- a/deps/deps.go
+++ b/deps/deps.go
@@ -16,6 +16,7 @@ import (
"github.com/gohugoio/hugo/langs"
"github.com/gohugoio/hugo/media"
"github.com/gohugoio/hugo/resources/page"
+ "github.com/gohugoio/hugo/resources/postpub"
"github.com/gohugoio/hugo/metrics"
"github.com/gohugoio/hugo/output"
@@ -78,6 +79,10 @@ type Deps struct {
// All the output formats available for the current site.
OutputFormatsConfig output.Formats
+ // FilenameHasPostProcessPrefix is a set of filenames in /public that
+ // contains a post-processing prefix.
+ FilenameHasPostProcessPrefix []string
+
templateProvider ResourceProvider
WithTemplate func(templ tpl.TemplateManager) error `json:"-"`
@@ -202,6 +207,7 @@ func New(cfg DepsCfg) (*Deps, error) {
var (
logger = cfg.Logger
fs = cfg.Fs
+ d *Deps
)
if cfg.TemplateProvider == nil {
@@ -239,6 +245,18 @@ func New(cfg DepsCfg) (*Deps, error) {
}
execHelper := hexec.New(securityConfig)
+ var filenameHasPostProcessPrefixMu sync.Mutex
+ cb := func(name string, match bool) {
+ if !match {
+ return
+ }
+ filenameHasPostProcessPrefixMu.Lock()
+ d.FilenameHasPostProcessPrefix = append(d.FilenameHasPostProcessPrefix, name)
+ filenameHasPostProcessPrefixMu.Unlock()
+
+ }
+ fs.PublishDir = hugofs.NewHasBytesReceiver(fs.PublishDir, cb, []byte(postpub.PostProcessPrefix))
+
ps, err := helpers.NewPathSpec(fs, cfg.Language, logger)
if err != nil {
return nil, fmt.Errorf("create PathSpec: %w", err)
@@ -274,7 +292,7 @@ func New(cfg DepsCfg) (*Deps, error) {
logDistinct := helpers.NewDistinctLogger(logger)
- d := &Deps{
+ d = &Deps{
Fs: fs,
Log: ignorableLogger,
LogDistinct: logDistinct,