From 35d04671d37e386ea9da376efd44006410157393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= Date: Tue, 24 Jun 2014 23:44:16 +0200 Subject: [PATCH] Add PluralizeListTitles option (default true) to allow disabling use of the inflect package --- commands/hugo.go | 8 +++++++- hugolib/site.go | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/commands/hugo.go b/commands/hugo.go index d3e3bea1e..f5c8415ae 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -51,7 +51,7 @@ Complete documentation is available at http://hugo.spf13.com`, 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 func Execute() { @@ -84,6 +84,7 @@ func init() { HugoCmd.PersistentFlags().StringVar(&LogFile, "logFile", "", "Log File path (if set, logging enabled automatically)") 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(&PluralizeListTitles, "pluralizeListTitles", true, "Pluralize titles in lists using inflect") HugoCmd.Flags().BoolVarP(&BuildWatch, "watch", "w", false, "watch filesystem for changes and recreate as needed") hugoCmdV = HugoCmd } @@ -119,6 +120,7 @@ func InitializeConfig() { viper.SetDefault("PygmentsStyle", "monokai") viper.SetDefault("PygmentsUseClasses", false) viper.SetDefault("DisableLiveReload", false) + viper.SetDefault("PluralizeListTitles", true) if hugoCmdV.PersistentFlags().Lookup("buildDrafts").Changed { viper.Set("BuildDrafts", Draft) @@ -144,6 +146,10 @@ func InitializeConfig() { viper.Set("Verbose", Verbose) } + if hugoCmdV.PersistentFlags().Lookup("pluralizeListTitles").Changed { + viper.Set("PluralizeListTitles", PluralizeListTitles) + } + if hugoCmdV.PersistentFlags().Lookup("logFile").Changed { viper.Set("LogFile", LogFile) } diff --git a/hugolib/site.go b/hugolib/site.go index 86b4e07b9..32c737415 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -676,7 +676,11 @@ func (s *Site) RenderListsOfTaxonomyTerms() (err error) { func (s *Site) RenderSectionLists() error { for section, data := range s.Sections { 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) n.Date = data[0].Page.Date n.Data["Pages"] = data.Pages()