mirror of
https://git.mills.io/prologic/zs
synced 2024-11-26 07: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 (
|
var (
|
||||||
configFile string
|
configFile string
|
||||||
enabledExtensions []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
|
// 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
|
var extensions []goldmark.Extender
|
||||||
for _, name := range enabledExtensions {
|
for _, name := range viper.GetStringSlice("extensions") {
|
||||||
if extender, valid := Extensions[name]; valid {
|
if extender, valid := Extensions[name]; valid {
|
||||||
extensions = append(extensions, extender)
|
extensions = append(extensions, extender)
|
||||||
} else {
|
} else {
|
||||||
@ -329,7 +317,7 @@ func globals() Vars {
|
|||||||
"keywords": viper.GetString("keywords"),
|
"keywords": viper.GetString("keywords"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if Production {
|
if viper.GetBool("production") {
|
||||||
vars["production"] = "1"
|
vars["production"] = "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,15 +654,18 @@ func init() {
|
|||||||
|
|
||||||
RootCmd.PersistentFlags().BoolP("debug", "D", false, "enable debug logging $($ZS_DEBUG)")
|
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().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().StringSliceP("extensions", "e", MapKeys(Extensions), "override and enable specific extensions")
|
||||||
RootCmd.PersistentFlags().BoolVarP(&Production, "production", "p", false, "enable production mode ($ZS_PRODUCTION)")
|
RootCmd.PersistentFlags().BoolP("production", "p", false, "enable production mode ($ZS_PRODUCTION)")
|
||||||
RootCmd.PersistentFlags().StringVarP(&Title, "title", "t", "", "site title ($ZS_TITLE)")
|
RootCmd.PersistentFlags().StringP("title", "t", "", "site title ($ZS_TITLE)")
|
||||||
RootCmd.PersistentFlags().StringVarP(&Description, "description", "d", "", "site description ($ZS_DESCRIPTION)")
|
RootCmd.PersistentFlags().StringP("description", "d", "", "site description ($ZS_DESCRIPTION)")
|
||||||
RootCmd.PersistentFlags().StringVarP(&Keywords, "keywords", "k", "", "site keywords ($ZS_KEYWORDS)")
|
RootCmd.PersistentFlags().StringP("keywords", "k", "", "site keywords ($ZS_KEYWORDS)")
|
||||||
|
|
||||||
viper.BindPFlag("debug", RootCmd.PersistentFlags().Lookup("debug"))
|
viper.BindPFlag("debug", RootCmd.PersistentFlags().Lookup("debug"))
|
||||||
viper.SetDefault("debug", false)
|
viper.SetDefault("debug", false)
|
||||||
|
|
||||||
|
viper.BindPFlag("extensions", RootCmd.PersistentFlags().Lookup("extensions"))
|
||||||
|
viper.SetDefault("extensions", MapKeys(Extensions))
|
||||||
|
|
||||||
viper.BindPFlag("production", RootCmd.PersistentFlags().Lookup("production"))
|
viper.BindPFlag("production", RootCmd.PersistentFlags().Lookup("production"))
|
||||||
viper.SetDefault("production", false)
|
viper.SetDefault("production", false)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user