From 5719af87279339d1d2bf5dc995349271a9aa5a64 Mon Sep 17 00:00:00 2001 From: adnano Date: Sun, 11 Apr 2021 17:40:11 -0400 Subject: [PATCH] dir: Don't index static files --- dir.go | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/dir.go b/dir.go index 3477c93..62c8c33 100644 --- a/dir.go +++ b/dir.go @@ -17,8 +17,8 @@ type Dir struct { Path string // Directory path. Pages []*Page // Pages in this directory. Dirs []*Dir // Subdirectories. - files map[string][]byte // Static files. index *Page // The index page. + feeds map[string][]byte // Feeds. inputExt string // input file extension outputExt string // output file extension @@ -34,7 +34,7 @@ func NewDir(path string) *Dir { } return &Dir{ Path: path, - files: map[string][]byte{}, + feeds: map[string][]byte{}, } } @@ -76,9 +76,6 @@ func (d *Dir) read(srcDir string, path string) error { } else { 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 { return err } - d.files[pathpkg.Join(d.Path, "atom.xml")] = b.Bytes() + d.feeds[pathpkg.Join(d.Path, "atom.xml")] = b.Bytes() } // Manipulate subdirectories @@ -150,19 +147,6 @@ func (d *Dir) write(dstDir string, format Format) error { 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 for _, page := range d.Pages { path, content := format.Format(page)