1
0
mirror of https://git.sr.ht/~adnano/kiln synced 2024-11-08 10:09:18 +01:00

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

@ -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)