var (
configFile string
enabledExtensions []string
-
- // Title site title
- Title string
-
- // Description site description
- Description string
-
- // Keywords site keywords
- Keywords string
-
- // Production is a global variable to conditionally build for production
- Production = false
)
// Extensions is a mapping of name to extension and the default set of extensions enabled
}
var extensions []goldmark.Extender
- for _, name := range enabledExtensions {
+ for _, name := range viper.GetStringSlice("extensions") {
if extender, valid := Extensions[name]; valid {
extensions = append(extensions, extender)
} else {
"keywords": viper.GetString("keywords"),
}
- if Production {
+ if viper.GetBool("production") {
vars["production"] = "1"
}
RootCmd.PersistentFlags().BoolP("debug", "D", false, "enable debug logging $($ZS_DEBUG)")
RootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "", "config file (default: .zs/config.yml)")
- RootCmd.PersistentFlags().StringSliceVarP(&enabledExtensions, "extensions", "e", MapKeys(Extensions), "override and enable specific extensions")
- RootCmd.PersistentFlags().BoolVarP(&Production, "production", "p", false, "enable production mode ($ZS_PRODUCTION)")
- RootCmd.PersistentFlags().StringVarP(&Title, "title", "t", "", "site title ($ZS_TITLE)")
- RootCmd.PersistentFlags().StringVarP(&Description, "description", "d", "", "site description ($ZS_DESCRIPTION)")
- RootCmd.PersistentFlags().StringVarP(&Keywords, "keywords", "k", "", "site keywords ($ZS_KEYWORDS)")
+ RootCmd.PersistentFlags().StringSliceP("extensions", "e", MapKeys(Extensions), "override and enable specific extensions")
+ RootCmd.PersistentFlags().BoolP("production", "p", false, "enable production mode ($ZS_PRODUCTION)")
+ RootCmd.PersistentFlags().StringP("title", "t", "", "site title ($ZS_TITLE)")
+ RootCmd.PersistentFlags().StringP("description", "d", "", "site description ($ZS_DESCRIPTION)")
+ RootCmd.PersistentFlags().StringP("keywords", "k", "", "site keywords ($ZS_KEYWORDS)")
viper.BindPFlag("debug", RootCmd.PersistentFlags().Lookup("debug"))
viper.SetDefault("debug", false)
+ viper.BindPFlag("extensions", RootCmd.PersistentFlags().Lookup("extensions"))
+ viper.SetDefault("extensions", MapKeys(Extensions))
+
viper.BindPFlag("production", RootCmd.PersistentFlags().Lookup("production"))
viper.SetDefault("production", false)