mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 09:23:09 +00:00
dir: Don't index static files
This commit is contained in:
parent
2808c44386
commit
78a05c255b
22
dir.go
22
dir.go
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue