mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-25 22:00:58 +02:00
Add support for multiple staticDirs
This commit adds support for multiple statDirs both on the global and language level. A simple `config.toml` example: ```bash staticDir = ["static1", "static2"] [languages] [languages.no] staticDir = ["staticDir_override", "static_no"] baseURL = "https://example.no" languageName = "Norsk" weight = 1 title = "På norsk" [languages.en] staticDir2 = "static_en" baseURL = "https://example.com" languageName = "English" weight = 2 title = "In English" ``` In the above, with no theme used: the English site will get its static files as a union of "static1", "static2" and "static_en". On file duplicates, the right-most version will win. the Norwegian site will get its static files as a union of "staticDir_override" and "static_no". This commit also concludes the Multihost support in #4027. Fixes #36 Closes #4027
This commit is contained in:
@@ -393,6 +393,19 @@ func (s *SiteInfo) BaseURL() template.URL {
|
||||
return template.URL(s.s.PathSpec.BaseURL.String())
|
||||
}
|
||||
|
||||
// ServerPort returns the port part of the BaseURL, 0 if none found.
|
||||
func (s *SiteInfo) ServerPort() int {
|
||||
ps := s.s.PathSpec.BaseURL.URL().Port()
|
||||
if ps == "" {
|
||||
return 0
|
||||
}
|
||||
p, err := strconv.Atoi(ps)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
// Used in tests.
|
||||
|
||||
type siteBuilderCfg struct {
|
||||
@@ -1806,7 +1819,7 @@ func (s *Site) renderAndWriteXML(name string, dest string, d interface{}, layout
|
||||
if s.Info.relativeURLs {
|
||||
path = []byte(helpers.GetDottedRelativePath(dest))
|
||||
} else {
|
||||
s := s.Cfg.GetString("baseURL")
|
||||
s := s.PathSpec.BaseURL.String()
|
||||
if !strings.HasSuffix(s, "/") {
|
||||
s += "/"
|
||||
}
|
||||
@@ -1864,7 +1877,7 @@ func (s *Site) renderAndWritePage(name string, dest string, p *PageOutput, layou
|
||||
if s.Info.relativeURLs {
|
||||
path = []byte(helpers.GetDottedRelativePath(dest))
|
||||
} else if s.Info.canonifyURLs {
|
||||
url := s.Cfg.GetString("baseURL")
|
||||
url := s.PathSpec.BaseURL.String()
|
||||
if !strings.HasSuffix(url, "/") {
|
||||
url += "/"
|
||||
}
|
||||
|
Reference in New Issue
Block a user