mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Support pages without folders
This commit is contained in:
parent
fc5e92cc24
commit
19538a1bd6
2 changed files with 22 additions and 0 deletions
|
@ -92,6 +92,9 @@ func initializePage(filename string) (page Page) {
|
|||
|
||||
func (p *Page) setSection() {
|
||||
x := strings.Split(p.FileName, string(os.PathSeparator))
|
||||
if len(x) <= 1 {
|
||||
return
|
||||
}
|
||||
|
||||
if section := x[len(x)-2]; section != "content" {
|
||||
p.Section = section
|
||||
|
|
19
hugolib/path_seperators_test.go
Normal file
19
hugolib/path_seperators_test.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package hugolib
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func TestDegenerateMissingFolderInPageFilename(t *testing.T) {
|
||||
p := NewPage(filepath.Join("foobar"))
|
||||
if p != nil {
|
||||
t.Fatalf("Creating a new Page without a subdirectory should result in nil page")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSettingOutFileOnPageContainsCorrectSlashes(t *testing.T) {
|
||||
s := NewSite(&Config{})
|
||||
p := NewPage(filepath.Join("sub", "foobar"))
|
||||
s.setOutFile(p)
|
||||
}
|
Loading…
Reference in a new issue