mirror of
https://git.mills.io/prologic/zs
synced 2024-11-22 05:16:11 +03:00
Fix setting extensions via config
This commit is contained in:
parent
a1308368b3
commit
320cc026ee
29
main.go
29
main.go
@ -70,18 +70,6 @@ var Parser goldmark.Markdown
|
||||
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
|
||||
@ -163,7 +151,7 @@ var RootCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -329,7 +317,7 @@ func globals() Vars {
|
||||
"keywords": viper.GetString("keywords"),
|
||||
}
|
||||
|
||||
if Production {
|
||||
if viper.GetBool("production") {
|
||||
vars["production"] = "1"
|
||||
}
|
||||
|
||||
@ -666,15 +654,18 @@ func init() {
|
||||
|
||||
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user