diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-05-21 14:25:16 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-05-22 14:14:35 +0200 |
commit | 2c3d4dfb745799b5de11f9ec0463a4ace19e97de (patch) | |
tree | 22f8dfe5b6f0bd39d66757119c2ea2ce5f83743d /hugolib/filesystems | |
parent | 1292d5a26af55ffd22512a01ae3a82c769e9bb01 (diff) | |
download | hugo-2c3d4dfb745799b5de11f9ec0463a4ace19e97de.tar.gz hugo-2c3d4dfb745799b5de11f9ec0463a4ace19e97de.zip |
Add cache busting config to support Tailwind 3
Fixes #10974
Diffstat (limited to 'hugolib/filesystems')
-rw-r--r-- | hugolib/filesystems/basefs.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go index b90111e26..ed0d36de1 100644 --- a/hugolib/filesystems/basefs.go +++ b/hugolib/filesystems/basefs.go @@ -76,6 +76,8 @@ type BaseFs struct { theBigFs *filesystemsCollector + workingDir string + // Locks. buildMu Lockable // <project>/.hugo_build.lock } @@ -201,6 +203,27 @@ func (fs *BaseFs) ResolveJSConfigFile(name string) string { return "" } +// MakePathRelative creates a relative path from the given filename. +// It returns both the component name (e.g. layouts) and the path relative to that. +func (fs *BaseFs) MakePathRelative(filename string) (string, string) { + for _, sfs := range fs.FileSystems() { + if sfs.Contains(filename) { + if s, found := sfs.MakePathRelative(filename); found { + return sfs.Name, s + } + } + } + // May be a static file. + if s := fs.MakeStaticPathRelative(filename); s != "" { + return files.ComponentFolderStatic, s + } + // Fall back to relative to the working dir. + if strings.HasPrefix(filename, fs.workingDir) { + return "", strings.TrimPrefix(filename, fs.workingDir) + } + return "", "" +} + // SourceFilesystems contains the different source file systems. These can be // composite file systems (theme and project etc.), and they have all root // set to the source type the provides: data, i18n, static, layouts. @@ -235,6 +258,7 @@ type SourceFilesystems struct { func (s *SourceFilesystems) FileSystems() []*SourceFilesystem { return []*SourceFilesystem{ s.Content, + s.Assets, s.Data, s.I18n, s.Layouts, @@ -466,6 +490,7 @@ func NewBase(p *paths.Paths, logger loggers.Logger, options ...func(*BaseFs) err WorkDir: fs.WorkingDirReadOnly, PublishFs: publishFs, PublishFsStatic: publishFsStatic, + workingDir: p.Cfg.BaseConfig().WorkingDir, buildMu: buildMu, } |