writing indexes under more configuration conditions - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit af1acfbce7c7d780856ac5f11646394f9c294293
DIR parent ad34be9d77f8abf948d36de4498e8955a02bbec6
HTML Author: spf13 <steve.francia@gmail.com>
Date: Mon, 7 Apr 2014 23:29:35 -0400
writing indexes under more configuration conditions
Diffstat:
M commands/hugo.go | 2 ++
M hugolib/site.go | 89 +++++++++++++++----------------
2 files changed, 46 insertions(+), 45 deletions(-)
---
DIR diff --git a/commands/hugo.go b/commands/hugo.go
@@ -146,6 +146,8 @@ func InitializeConfig() {
if VerboseLog {
jww.SetLogThreshold(jww.LevelDebug)
}
+
+ jww.INFO.Println("Using config file:", viper.ConfigFileUsed())
}
func build(watches ...bool) {
DIR diff --git a/hugolib/site.go b/hugolib/site.go
@@ -302,7 +302,10 @@ func (s *Site) BuildSiteMeta() (err error) {
s.Indexes = make(IndexList)
s.Sections = make(Index)
- for _, plural := range viper.GetStringMapString("Indexes") {
+ indexes := viper.GetStringMapString("Indexes")
+ jww.INFO.Printf("found indexes: %#v\n", indexes)
+
+ for _, plural := range indexes {
s.Indexes[plural] = make(Index)
for _, p := range s.Pages {
vals := p.GetParam(plural)
@@ -421,37 +424,35 @@ func (s *Site) RenderPages() (err error) {
func (s *Site) RenderIndexes() (err error) {
var wg sync.WaitGroup
- indexes, ok := viper.Get("Indexes").(map[string]string)
- if ok {
- for sing, pl := range indexes {
- for key, oo := range s.Indexes[pl] {
- wg.Add(1)
- go func(k string, o WeightedPages, singular string, plural string) (err error) {
- defer wg.Done()
- base := plural + "/" + k
- n := s.NewNode()
- n.Title = strings.Title(k)
- s.setUrls(n, base)
- n.Date = o[0].Page.Date
- n.Data[singular] = o
- n.Data["Pages"] = o.Pages()
- layout := "indexes/" + singular + ".html"
- err = s.render(n, base+".html", layout)
+ indexes := viper.GetStringMapString("Indexes")
+ for sing, pl := range indexes {
+ for key, oo := range s.Indexes[pl] {
+ wg.Add(1)
+ go func(k string, o WeightedPages, singular string, plural string) (err error) {
+ defer wg.Done()
+ base := plural + "/" + k
+ n := s.NewNode()
+ n.Title = strings.Title(k)
+ s.setUrls(n, base)
+ n.Date = o[0].Page.Date
+ n.Data[singular] = o
+ n.Data["Pages"] = o.Pages()
+ layout := "indexes/" + singular + ".html"
+ err = s.render(n, base+".html", layout)
+ if err != nil {
+ return err
+ }
+
+ if a := s.Tmpl.Lookup("rss.xml"); a != nil {
+ // XML Feed
+ s.setUrls(n, base+".xml")
+ err := s.render(n, base+".xml", "rss.xml")
if err != nil {
return err
}
-
- if a := s.Tmpl.Lookup("rss.xml"); a != nil {
- // XML Feed
- s.setUrls(n, base+".xml")
- err := s.render(n, base+".xml", "rss.xml")
- if err != nil {
- return err
- }
- }
- return
- }(key, oo, sing, pl)
- }
+ }
+ return
+ }(key, oo, sing, pl)
}
}
wg.Wait()
@@ -462,22 +463,20 @@ func (s *Site) RenderIndexesIndexes() (err error) {
layout := "indexes/indexes.html"
if s.Tmpl.Lookup(layout) != nil {
- indexes, ok := viper.Get("Indexes").(map[string]string)
- if ok {
- for singular, plural := range indexes {
- n := s.NewNode()
- n.Title = strings.Title(plural)
- s.setUrls(n, plural)
- n.Data["Singular"] = singular
- n.Data["Plural"] = plural
- n.Data["Index"] = s.Indexes[plural]
- // keep the following just for legacy reasons
- n.Data["OrderedIndex"] = s.Indexes[plural]
-
- err := s.render(n, plural+"/index.html", layout)
- if err != nil {
- return err
- }
+ indexes := viper.GetStringMapString("Indexes")
+ for singular, plural := range indexes {
+ n := s.NewNode()
+ n.Title = strings.Title(plural)
+ s.setUrls(n, plural)
+ n.Data["Singular"] = singular
+ n.Data["Plural"] = plural
+ n.Data["Index"] = s.Indexes[plural]
+ // keep the following just for legacy reasons
+ n.Data["OrderedIndex"] = s.Indexes[plural]
+
+ err := s.render(n, plural+"/index.html", layout)
+ if err != nil {
+ return err
}
}
}