mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 22:21:07 +03:00
Big refactor of how source files are used. Also added default destination extension option.
This commit is contained in:
parent
24bbfe7d32
commit
5dfc1dedb8
24 changed files with 646 additions and 465 deletions
|
@ -3,17 +3,15 @@ package source
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"path"
|
||||
)
|
||||
|
||||
type ByteSource struct {
|
||||
Name string
|
||||
Content []byte
|
||||
Section string
|
||||
}
|
||||
|
||||
func (b *ByteSource) String() string {
|
||||
return fmt.Sprintf("%s %s %s", b.Name, b.Section, string(b.Content))
|
||||
return fmt.Sprintf("%s %s", b.Name, string(b.Content))
|
||||
}
|
||||
|
||||
type InMemorySource struct {
|
||||
|
@ -23,12 +21,7 @@ type InMemorySource struct {
|
|||
func (i *InMemorySource) Files() (files []*File) {
|
||||
files = make([]*File, len(i.ByteSource))
|
||||
for i, fake := range i.ByteSource {
|
||||
files[i] = &File{
|
||||
LogicalName: fake.Name,
|
||||
Contents: bytes.NewReader(fake.Content),
|
||||
Section: fake.Section,
|
||||
Dir: path.Dir(fake.Name),
|
||||
}
|
||||
files[i] = NewFileWithContents(fake.Name, bytes.NewReader(fake.Content))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue