mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
writing indexes under more configuration conditions
This commit is contained in:
parent
ad34be9d77
commit
af1acfbce7
2 changed files with 45 additions and 44 deletions
|
@ -146,6 +146,8 @@ func InitializeConfig() {
|
||||||
if VerboseLog {
|
if VerboseLog {
|
||||||
jww.SetLogThreshold(jww.LevelDebug)
|
jww.SetLogThreshold(jww.LevelDebug)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jww.INFO.Println("Using config file:", viper.ConfigFileUsed())
|
||||||
}
|
}
|
||||||
|
|
||||||
func build(watches ...bool) {
|
func build(watches ...bool) {
|
||||||
|
|
|
@ -302,7 +302,10 @@ func (s *Site) BuildSiteMeta() (err error) {
|
||||||
s.Indexes = make(IndexList)
|
s.Indexes = make(IndexList)
|
||||||
s.Sections = make(Index)
|
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)
|
s.Indexes[plural] = make(Index)
|
||||||
for _, p := range s.Pages {
|
for _, p := range s.Pages {
|
||||||
vals := p.GetParam(plural)
|
vals := p.GetParam(plural)
|
||||||
|
@ -421,37 +424,35 @@ func (s *Site) RenderPages() (err error) {
|
||||||
func (s *Site) RenderIndexes() (err error) {
|
func (s *Site) RenderIndexes() (err error) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
indexes, ok := viper.Get("Indexes").(map[string]string)
|
indexes := viper.GetStringMapString("Indexes")
|
||||||
if ok {
|
for sing, pl := range indexes {
|
||||||
for sing, pl := range indexes {
|
for key, oo := range s.Indexes[pl] {
|
||||||
for key, oo := range s.Indexes[pl] {
|
wg.Add(1)
|
||||||
wg.Add(1)
|
go func(k string, o WeightedPages, singular string, plural string) (err error) {
|
||||||
go func(k string, o WeightedPages, singular string, plural string) (err error) {
|
defer wg.Done()
|
||||||
defer wg.Done()
|
base := plural + "/" + k
|
||||||
base := plural + "/" + k
|
n := s.NewNode()
|
||||||
n := s.NewNode()
|
n.Title = strings.Title(k)
|
||||||
n.Title = strings.Title(k)
|
s.setUrls(n, base)
|
||||||
s.setUrls(n, base)
|
n.Date = o[0].Page.Date
|
||||||
n.Date = o[0].Page.Date
|
n.Data[singular] = o
|
||||||
n.Data[singular] = o
|
n.Data["Pages"] = o.Pages()
|
||||||
n.Data["Pages"] = o.Pages()
|
layout := "indexes/" + singular + ".html"
|
||||||
layout := "indexes/" + singular + ".html"
|
err = s.render(n, base+".html", layout)
|
||||||
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if a := s.Tmpl.Lookup("rss.xml"); a != nil {
|
return
|
||||||
// XML Feed
|
}(key, oo, sing, pl)
|
||||||
s.setUrls(n, base+".xml")
|
|
||||||
err := s.render(n, base+".xml", "rss.xml")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}(key, oo, sing, pl)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
@ -462,22 +463,20 @@ func (s *Site) RenderIndexesIndexes() (err error) {
|
||||||
layout := "indexes/indexes.html"
|
layout := "indexes/indexes.html"
|
||||||
if s.Tmpl.Lookup(layout) != nil {
|
if s.Tmpl.Lookup(layout) != nil {
|
||||||
|
|
||||||
indexes, ok := viper.Get("Indexes").(map[string]string)
|
indexes := viper.GetStringMapString("Indexes")
|
||||||
if ok {
|
for singular, plural := range indexes {
|
||||||
for singular, plural := range indexes {
|
n := s.NewNode()
|
||||||
n := s.NewNode()
|
n.Title = strings.Title(plural)
|
||||||
n.Title = strings.Title(plural)
|
s.setUrls(n, plural)
|
||||||
s.setUrls(n, plural)
|
n.Data["Singular"] = singular
|
||||||
n.Data["Singular"] = singular
|
n.Data["Plural"] = plural
|
||||||
n.Data["Plural"] = plural
|
n.Data["Index"] = s.Indexes[plural]
|
||||||
n.Data["Index"] = s.Indexes[plural]
|
// keep the following just for legacy reasons
|
||||||
// keep the following just for legacy reasons
|
n.Data["OrderedIndex"] = s.Indexes[plural]
|
||||||
n.Data["OrderedIndex"] = s.Indexes[plural]
|
|
||||||
|
|
||||||
err := s.render(n, plural+"/index.html", layout)
|
err := s.render(n, plural+"/index.html", layout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue