diff --git a/dir.go b/dir.go index 24f63bb..b0c95a7 100644 --- a/dir.go +++ b/dir.go @@ -153,14 +153,8 @@ func (d *Dir) _read(srcDir, path string, task *Task, cfg *Site) error { // process processes the directory's contents. func (d *Dir) process(cfg *Site, task *Task) error { - // build feeds - // this must happen before the page processing - // to have an unprocessed Page.Content - // 192: d.Pages[i].Content = b.String() - for _, feed := range task.Feeds { - if d.path != feed.InputDir { - continue - } + // Build feeds before templates are applied to the page contents + for _, feed := range task.feeds[d.path] { b, err := d.buildFeed(cfg, feed) if err != nil { return err diff --git a/site.go b/site.go index 189a9f7..e69892e 100644 --- a/site.go +++ b/site.go @@ -35,6 +35,7 @@ type Task struct { OutputDir string `toml:"output_dir"` // output directory UglyURLs bool `toml:"ugly_urls"` // whether to use ugly URLs Feeds []Feed `toml:"feeds"` + feeds map[string][]Feed } type Feed struct { @@ -91,6 +92,14 @@ func LoadSite(config string) (*Site, error) { return nil, err } + // Populate task feeds map + for _, task := range site.Tasks { + task.feeds = map[string][]Feed{} + for _, feed := range task.Feeds { + task.feeds[feed.InputDir] = append(task.feeds[feed.InputDir], feed) + } + } + // deprecate [feeds] if len(site.Feeds) > 0 { log.Println("The [feeds] configuration is deprecated")