mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
Handle themes in the new file cache (for images, assets)
In the newly consolidated file cache implementation, we forgot that we also look in the theme(s) for assets (SCSS transformations etc.), which is not good for Netlify and the demo sites. Fixes #5460
This commit is contained in:
@@ -81,6 +81,7 @@ type SourceFilesystems struct {
|
||||
Layouts *SourceFilesystem
|
||||
Archetypes *SourceFilesystem
|
||||
Assets *SourceFilesystem
|
||||
Resources *SourceFilesystem
|
||||
|
||||
// This is a unified read-only view of the project's and themes' workdir.
|
||||
Work *SourceFilesystem
|
||||
@@ -375,6 +376,13 @@ func (b *sourceFilesystemsBuilder) Build() (*SourceFilesystems, error) {
|
||||
}
|
||||
b.result.Assets = sfs
|
||||
|
||||
sfs, err = b.createFs(true, false, "resourceDir", "resources")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b.result.Resources = sfs
|
||||
|
||||
sfs, err = b.createFs(false, true, "", "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@@ -108,6 +108,7 @@ theme = ["atheme"]
|
||||
checkFileCount(bfs.Data.Fs, "", assert, 9) // 7 + 2 themes
|
||||
checkFileCount(bfs.Archetypes.Fs, "", assert, 10) // 8 + 2 themes
|
||||
checkFileCount(bfs.Assets.Fs, "", assert, 9)
|
||||
checkFileCount(bfs.Resources.Fs, "", assert, 10)
|
||||
checkFileCount(bfs.Work.Fs, "", assert, 78)
|
||||
|
||||
assert.Equal([]string{filepath.FromSlash("/my/work/mydata"), filepath.FromSlash("/my/work/themes/btheme/data"), filepath.FromSlash("/my/work/themes/atheme/data")}, bfs.Data.Dirnames)
|
||||
@@ -228,6 +229,8 @@ func TestRealDirs(t *testing.T) {
|
||||
assert.Equal(filepath.Join(root, "myassets/scss"), realDirs[0])
|
||||
assert.Equal(filepath.Join(themesDir, "mytheme/assets/scss"), realDirs[len(realDirs)-1])
|
||||
|
||||
checkFileCount(bfs.Resources.Fs, "", assert, 3)
|
||||
|
||||
assert.NotNil(bfs.themeFs)
|
||||
fi, b, err := bfs.themeFs.(afero.Lstater).LstatIfPossible(filepath.Join("resources", "t1.txt"))
|
||||
assert.NoError(err)
|
||||
|
Reference in New Issue
Block a user