summaryrefslogtreecommitdiffstats
path: root/commands/hugo.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-11-02 08:25:20 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-11-17 11:01:46 +0100
commit2e0465764b5dacc511b977b1c9aa07324ad0ee9c (patch)
treeae5a32eb9340e4c0e78e063228821edc29037631 /commands/hugo.go
parent6233ddf9d19b51f69c0c4a796d88732d1700e585 (diff)
Add multilingual multihost support
This commit adds multihost support when more than one language is configured and `baseURL` is set per language. Updates #4027
Diffstat (limited to 'commands/hugo.go')
-rw-r--r--commands/hugo.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/commands/hugo.go b/commands/hugo.go
index 63c5e3159..1714c8035 100644
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -526,6 +526,7 @@ func (c *commandeer) watchConfig() {
func (c *commandeer) build(watches ...bool) error {
if err := c.copyStatic(); err != nil {
+ // TODO(bep) multihost
return fmt.Errorf("Error copying static files to %s: %s", c.PathSpec().AbsPathify(c.Cfg.GetString("publishDir")), err)
}
watch := false
@@ -593,6 +594,24 @@ func (c *commandeer) getStaticSourceFs() afero.Fs {
func (c *commandeer) copyStatic() error {
publishDir := c.PathSpec().AbsPathify(c.Cfg.GetString("publishDir")) + helpers.FilePathSeparator
+ roots := c.roots()
+
+ if len(roots) == 0 {
+ return c.copyStaticTo(publishDir)
+ }
+
+ for _, root := range roots {
+ dir := filepath.Join(publishDir, root)
+ if err := c.copyStaticTo(dir); err != nil {
+ return err
+ }
+ }
+
+ return nil
+
+}
+
+func (c *commandeer) copyStaticTo(publishDir string) error {
// If root, remove the second '/'
if publishDir == "//" {
@@ -893,6 +912,7 @@ func (c *commandeer) newWatcher(port int) error {
if c.Cfg.GetBool("forceSyncStatic") {
c.Logger.FEEDBACK.Printf("Syncing all static files\n")
+ // TODO(bep) multihost
err := c.copyStatic()
if err != nil {
utils.StopOnErr(c.Logger, err, fmt.Sprintf("Error copying static files to %s", publishDir))