Support pages without folders - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 19538a1bd6732930977654b9a61c33adbb9e533f
DIR parent fc5e92cc247b2414bff70dfe5e82ac897eddb280
HTML Author: Noah Campbell <noahcampbell@gmail.com>
Date: Sat, 3 Aug 2013 10:51:21 -0700
Support pages without folders
Diffstat:
M hugolib/page.go | 3 +++
A hugolib/path_seperators_test.go | 19 +++++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
---
DIR diff --git a/hugolib/page.go b/hugolib/page.go
@@ -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
DIR diff --git a/hugolib/path_seperators_test.go b/hugolib/path_seperators_test.go
@@ -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)
+}