dir: Pass Date to templates

This commit is contained in:
adnano 2021-04-26 14:47:45 -04:00
parent 0a6d61eb5c
commit 5be3306c6d

16
dir.go
View file

@ -16,13 +16,14 @@ import (
// Dir represents a directory.
type Dir struct {
Title string // Directory title.
Content string // Directory index content.
Path string // Directory path.
Pages []*Page // Pages in this directory.
Dirs []*Dir // Subdirectories.
index *Page // The index page.
feed []byte // Atom feed.
Title string
Date time.Time
Content string
Path string
Pages []*Page
Dirs []*Dir
index *Page // The index page.
feed []byte // Atom feed.
}
// NewDir returns a new Dir with the given path.
@ -76,6 +77,7 @@ func (d *Dir) read(srcDir, path string, task *Task) error {
if strings.TrimSuffix(name, ext) == "index" {
d.index = NewPage(d.Path, content)
d.Title = d.index.Title
d.Date = d.index.Date
d.Content = d.index.Content
} else {
d.Pages = append(d.Pages, NewPage(path, content))