mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
52e8c7a0ac
This change allows for top level html content to exists.
34 lines
605 B
Go
34 lines
605 B
Go
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))
|
|
}
|
|
|
|
type InMemorySource struct {
|
|
ByteSource []ByteSource
|
|
}
|
|
|
|
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),
|
|
}
|
|
}
|
|
return
|
|
}
|