add option for #106
parent
55f4b75529
commit
6ef2cf88e0
2
hugo.go
2
hugo.go
|
@ -133,7 +133,9 @@ func (h Hugo) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
|
|||
|
||||
// RunHugo is used to run the static website generator
|
||||
func RunHugo(c *Config, force bool) {
|
||||
if c.CleanPublic {
|
||||
os.RemoveAll(c.Root + "public")
|
||||
}
|
||||
|
||||
// Prevent running if watching is enabled
|
||||
if b, pos := variables.StringInSlice("--watch", c.Args); b && !force {
|
||||
|
|
12
setup.go
12
setup.go
|
@ -10,6 +10,7 @@ import (
|
|||
"os/exec"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hacdias/caddy-filemanager"
|
||||
|
@ -70,6 +71,7 @@ type Config struct {
|
|||
Args []string // Hugo arguments
|
||||
BaseURL string // BaseURL of admin interface
|
||||
WebDavURL string
|
||||
CleanPublic bool
|
||||
BeforePublish config.CommandFunc
|
||||
AfterPublish config.CommandFunc
|
||||
}
|
||||
|
@ -127,6 +129,16 @@ func parse(c *caddy.Controller, root string) (*Config, *filemanager.FileManager,
|
|||
}
|
||||
|
||||
cfg.Args = append(cfg.Args, "--"+flag+"="+value)
|
||||
case "clean_public":
|
||||
if !c.NextArg() {
|
||||
return cfg, &filemanager.FileManager{}, c.ArgErr()
|
||||
}
|
||||
|
||||
cfg.CleanPublic, err = strconv.ParseBool(c.Val())
|
||||
|
||||
if err != nil {
|
||||
return cfg, &filemanager.FileManager{}, c.ArgErr()
|
||||
}
|
||||
case "before_publish":
|
||||
if cfg.BeforePublish, err = config.CommandRunner(c); err != nil {
|
||||
return cfg, &filemanager.FileManager{}, err
|
||||
|
|
Loading…
Reference in New Issue