dir: Don't index static files

This commit is contained in:
adnano 2021-04-11 17:40:11 -04:00
parent 9edacc1541
commit 5719af8727

22
dir.go
View file

@ -17,8 +17,8 @@ type Dir struct {
Path string // Directory path. Path string // Directory path.
Pages []*Page // Pages in this directory. Pages []*Page // Pages in this directory.
Dirs []*Dir // Subdirectories. Dirs []*Dir // Subdirectories.
files map[string][]byte // Static files.
index *Page // The index page. index *Page // The index page.
feeds map[string][]byte // Feeds.
inputExt string // input file extension inputExt string // input file extension
outputExt string // output file extension outputExt string // output file extension
@ -34,7 +34,7 @@ func NewDir(path string) *Dir {
} }
return &Dir{ return &Dir{
Path: path, Path: path,
files: map[string][]byte{}, feeds: map[string][]byte{},
} }
} }
@ -76,9 +76,6 @@ func (d *Dir) read(srcDir string, path string) error {
} else { } else {
d.Pages = append(d.Pages, NewPage(path, content)) d.Pages = append(d.Pages, NewPage(path, content))
} }
} else {
// Static file
d.files[path] = content
} }
} }
} }
@ -130,7 +127,7 @@ func (d *Dir) manipulate(cfg *Config) error {
if err := tmpl.Execute(&b, feed); err != nil { if err := tmpl.Execute(&b, feed); err != nil {
return err return err
} }
d.files[pathpkg.Join(d.Path, "atom.xml")] = b.Bytes() d.feeds[pathpkg.Join(d.Path, "atom.xml")] = b.Bytes()
} }
// Manipulate subdirectories // Manipulate subdirectories
@ -150,19 +147,6 @@ func (d *Dir) write(dstDir string, format Format) error {
return err return err
} }
// Write static files
for path := range d.files {
dstPath := pathpkg.Join(dstDir, path)
f, err := os.Create(dstPath)
if err != nil {
return err
}
data := d.files[path]
if _, err := f.Write(data); err != nil {
return err
}
}
// Write pages // Write pages
for _, page := range d.Pages { for _, page := range d.Pages {
path, content := format.Format(page) path, content := format.Format(page)