mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 22:50:35 +03:00
parent
53ade40ba4
commit
36220851e4
3 changed files with 49 additions and 14 deletions
|
@ -506,3 +506,31 @@ weight = 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMountsProject(t *testing.T) {
|
||||||
|
|
||||||
|
config := `
|
||||||
|
|
||||||
|
baseURL="https://example.org"
|
||||||
|
|
||||||
|
[module]
|
||||||
|
[[module.mounts]]
|
||||||
|
source="mycontent"
|
||||||
|
target="content"
|
||||||
|
|
||||||
|
`
|
||||||
|
b := newTestSitesBuilder(t).
|
||||||
|
WithConfigFile("toml", config).
|
||||||
|
WithSourceFile(filepath.Join("mycontent", "mypage.md"), `
|
||||||
|
---
|
||||||
|
title: "My Page"
|
||||||
|
---
|
||||||
|
|
||||||
|
`)
|
||||||
|
|
||||||
|
b.Build(BuildCfg{})
|
||||||
|
|
||||||
|
//helpers.PrintFs(b.H.Fs.Source, "public", os.Stdout)
|
||||||
|
|
||||||
|
b.AssertFileContent("public/mypage/index.html", "Permalink: https://example.org/mypage/")
|
||||||
|
}
|
||||||
|
|
|
@ -305,21 +305,25 @@ func (c *collector) addAndRecurse(owner *moduleAdapter, disabled bool) error {
|
||||||
func (c *collector) applyMounts(moduleImport Import, mod *moduleAdapter) error {
|
func (c *collector) applyMounts(moduleImport Import, mod *moduleAdapter) error {
|
||||||
mounts := moduleImport.Mounts
|
mounts := moduleImport.Mounts
|
||||||
|
|
||||||
if !mod.projectMod && len(mounts) == 0 {
|
modConfig := mod.Config()
|
||||||
modConfig := mod.Config()
|
|
||||||
|
if len(mounts) == 0 {
|
||||||
|
// Mounts not defined by the import.
|
||||||
mounts = modConfig.Mounts
|
mounts = modConfig.Mounts
|
||||||
if len(mounts) == 0 {
|
|
||||||
// Create default mount points for every component folder that
|
}
|
||||||
// exists in the module.
|
|
||||||
for _, componentFolder := range files.ComponentFolders {
|
if !mod.projectMod && len(mounts) == 0 {
|
||||||
sourceDir := filepath.Join(mod.Dir(), componentFolder)
|
// Create default mount points for every component folder that
|
||||||
_, err := c.fs.Stat(sourceDir)
|
// exists in the module.
|
||||||
if err == nil {
|
for _, componentFolder := range files.ComponentFolders {
|
||||||
mounts = append(mounts, Mount{
|
sourceDir := filepath.Join(mod.Dir(), componentFolder)
|
||||||
Source: componentFolder,
|
_, err := c.fs.Stat(sourceDir)
|
||||||
Target: componentFolder,
|
if err == nil {
|
||||||
})
|
mounts = append(mounts, Mount{
|
||||||
}
|
Source: componentFolder,
|
||||||
|
Target: componentFolder,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,9 @@ func ApplyProjectConfigDefaults(cfg config.Provider, mod Module) error {
|
||||||
mounts = append(mounts, Mount{Source: dirKey.component, Target: dirKey.component})
|
mounts = append(mounts, Mount{Source: dirKey.component, Target: dirKey.component})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prepend the mounts from configuration.
|
||||||
|
mounts = append(moda.mounts, mounts...)
|
||||||
|
|
||||||
// Remove duplicates
|
// Remove duplicates
|
||||||
seen := make(map[string]bool)
|
seen := make(map[string]bool)
|
||||||
tmp := mounts[:0]
|
tmp := mounts[:0]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue