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. // Dir represents a directory.
type Dir struct { type Dir struct {
Title string // Directory title. Title string
Content string // Directory index content. Date time.Time
Path string // Directory path. Content string
Pages []*Page // Pages in this directory. Path string
Dirs []*Dir // Subdirectories. Pages []*Page
index *Page // The index page. Dirs []*Dir
feed []byte // Atom feed. index *Page // The index page.
feed []byte // Atom feed.
} }
// NewDir returns a new Dir with the given path. // 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" { if strings.TrimSuffix(name, ext) == "index" {
d.index = NewPage(d.Path, content) d.index = NewPage(d.Path, content)
d.Title = d.index.Title d.Title = d.index.Title
d.Date = d.index.Date
d.Content = d.index.Content d.Content = d.index.Content
} else { } else {
d.Pages = append(d.Pages, NewPage(path, content)) d.Pages = append(d.Pages, NewPage(path, content))