buildDrafts from config
This commit is contained in:
parent
e2c8c278c5
commit
fe3351a2c9
1 changed files with 8 additions and 5 deletions
13
main.go
13
main.go
|
@ -19,14 +19,13 @@ const (
|
||||||
defaultSource = "content"
|
defaultSource = "content"
|
||||||
defaultDestination = "public"
|
defaultDestination = "public"
|
||||||
defaultConfigPath = "config.toml"
|
defaultConfigPath = "config.toml"
|
||||||
defaultUglyURLs = false
|
|
||||||
|
|
||||||
defaultPermalinkFormat = "/:year/:month/:title/"
|
defaultPermalinkFormat = "/:year/:month/:title/"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var ext, pipe, source, destination, cfgPath string
|
var ext, pipe, source, destination, cfgPath string
|
||||||
var noSectionList, withDrafts bool
|
var noSectionList bool
|
||||||
|
|
||||||
flag.StringVar(&ext, "ext", defaultExt, "ext to look for templates in ./layout")
|
flag.StringVar(&ext, "ext", defaultExt, "ext to look for templates in ./layout")
|
||||||
flag.StringVar(&pipe, "pipe", defaultProcessor, "pipe markdown to this program for content processing")
|
flag.StringVar(&pipe, "pipe", defaultProcessor, "pipe markdown to this program for content processing")
|
||||||
|
@ -34,11 +33,10 @@ func main() {
|
||||||
flag.StringVar(&destination, "destination", defaultDestination, "output directory")
|
flag.StringVar(&destination, "destination", defaultDestination, "output directory")
|
||||||
flag.StringVar(&cfgPath, "config", defaultConfigPath, "hugo config path")
|
flag.StringVar(&cfgPath, "config", defaultConfigPath, "hugo config path")
|
||||||
flag.BoolVar(&noSectionList, "no-section-list", false, "disable auto append of section content lists")
|
flag.BoolVar(&noSectionList, "no-section-list", false, "disable auto append of section content lists")
|
||||||
flag.BoolVar(&withDrafts, "enable-withDrafts", false, "include withDrafts in processing and output")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// what are we doing
|
// what are we doing
|
||||||
fmt.Printf("converting hugo markdown to %v with %v\n", ext, pipe)
|
fmt.Printf("hugoext: converting hugo markdown to %v with %v\n", ext, pipe)
|
||||||
|
|
||||||
// config
|
// config
|
||||||
cfg, err := config.FromFile(afero.NewOsFs(), "config.toml")
|
cfg, err := config.FromFile(afero.NewOsFs(), "config.toml")
|
||||||
|
@ -51,6 +49,11 @@ func main() {
|
||||||
fmt.Println("config: no uglyURLs set, using default: ", uglyURLs)
|
fmt.Println("config: no uglyURLs set, using default: ", uglyURLs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildDrafts := cfg.GetBool("buildDrafts")
|
||||||
|
if !cfg.IsSet("buildDrafts") {
|
||||||
|
fmt.Println("config: no buildDrafts set, using default: ", buildDrafts)
|
||||||
|
}
|
||||||
|
|
||||||
permalinks := cfg.GetStringMapString("permalinks")
|
permalinks := cfg.GetStringMapString("permalinks")
|
||||||
if permalinks == nil {
|
if permalinks == nil {
|
||||||
fmt.Println("config: no permalinks set, using default: ", defaultPermalinkFormat)
|
fmt.Println("config: no permalinks set, using default: ", defaultPermalinkFormat)
|
||||||
|
@ -80,7 +83,7 @@ func main() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//fmt.Printf("%s -> %s (%d)\n", file.Source, file.Destination, len(file.Body))
|
//fmt.Printf("%s -> %s (%d)\n", file.Source, file.Destination, len(file.Body))
|
||||||
if file.Draft && !withDrafts {
|
if file.Draft && !buildDrafts {
|
||||||
fmt.Printf("skipping draft %s (%dbytes)\n", file.Source, len(file.Body))
|
fmt.Printf("skipping draft %s (%dbytes)\n", file.Source, len(file.Body))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue