Add PluralizeListTitles option (default true) to allow disabling use of the inflect package

This commit is contained in:
Kristoffer Grönlund 2014-06-24 23:44:16 +02:00 committed by spf13
parent 3eb480a62f
commit 35d04671d3
2 changed files with 12 additions and 2 deletions

View file

@ -51,7 +51,7 @@ Complete documentation is available at http://hugo.spf13.com`,
var hugoCmdV *cobra.Command var hugoCmdV *cobra.Command
var BuildWatch, Draft, Future, UglyUrls, Verbose, Logging, VerboseLog, DisableRSS, DisableSitemap bool var BuildWatch, Draft, Future, UglyUrls, Verbose, Logging, VerboseLog, DisableRSS, DisableSitemap, PluralizeListTitles bool
var Source, Destination, Theme, BaseUrl, CfgFile, LogFile string var Source, Destination, Theme, BaseUrl, CfgFile, LogFile string
func Execute() { func Execute() {
@ -84,6 +84,7 @@ func init() {
HugoCmd.PersistentFlags().StringVar(&LogFile, "logFile", "", "Log File path (if set, logging enabled automatically)") HugoCmd.PersistentFlags().StringVar(&LogFile, "logFile", "", "Log File path (if set, logging enabled automatically)")
HugoCmd.PersistentFlags().BoolVar(&VerboseLog, "verboseLog", false, "verbose logging") HugoCmd.PersistentFlags().BoolVar(&VerboseLog, "verboseLog", false, "verbose logging")
HugoCmd.PersistentFlags().BoolVar(&nitro.AnalysisOn, "stepAnalysis", false, "display memory and timing of different steps of the program") HugoCmd.PersistentFlags().BoolVar(&nitro.AnalysisOn, "stepAnalysis", false, "display memory and timing of different steps of the program")
HugoCmd.PersistentFlags().BoolVar(&PluralizeListTitles, "pluralizeListTitles", true, "Pluralize titles in lists using inflect")
HugoCmd.Flags().BoolVarP(&BuildWatch, "watch", "w", false, "watch filesystem for changes and recreate as needed") HugoCmd.Flags().BoolVarP(&BuildWatch, "watch", "w", false, "watch filesystem for changes and recreate as needed")
hugoCmdV = HugoCmd hugoCmdV = HugoCmd
} }
@ -119,6 +120,7 @@ func InitializeConfig() {
viper.SetDefault("PygmentsStyle", "monokai") viper.SetDefault("PygmentsStyle", "monokai")
viper.SetDefault("PygmentsUseClasses", false) viper.SetDefault("PygmentsUseClasses", false)
viper.SetDefault("DisableLiveReload", false) viper.SetDefault("DisableLiveReload", false)
viper.SetDefault("PluralizeListTitles", true)
if hugoCmdV.PersistentFlags().Lookup("buildDrafts").Changed { if hugoCmdV.PersistentFlags().Lookup("buildDrafts").Changed {
viper.Set("BuildDrafts", Draft) viper.Set("BuildDrafts", Draft)
@ -144,6 +146,10 @@ func InitializeConfig() {
viper.Set("Verbose", Verbose) viper.Set("Verbose", Verbose)
} }
if hugoCmdV.PersistentFlags().Lookup("pluralizeListTitles").Changed {
viper.Set("PluralizeListTitles", PluralizeListTitles)
}
if hugoCmdV.PersistentFlags().Lookup("logFile").Changed { if hugoCmdV.PersistentFlags().Lookup("logFile").Changed {
viper.Set("LogFile", LogFile) viper.Set("LogFile", LogFile)
} }

View file

@ -676,7 +676,11 @@ func (s *Site) RenderListsOfTaxonomyTerms() (err error) {
func (s *Site) RenderSectionLists() error { func (s *Site) RenderSectionLists() error {
for section, data := range s.Sections { for section, data := range s.Sections {
n := s.NewNode() n := s.NewNode()
n.Title = strings.Title(inflect.Pluralize(section)) if viper.GetBool("PluralizeListTitles") {
n.Title = strings.Title(inflect.Pluralize(section))
} else {
n.Title = strings.Title(section)
}
s.setUrls(n, section) s.setUrls(n, section)
n.Date = data[0].Page.Date n.Date = data[0].Page.Date
n.Data["Pages"] = data.Pages() n.Data["Pages"] = data.Pages()