Fixed bug where Url specified in front matter as pretty url wouldnt render
authorMark Sanborn <marcrosoft@gmail.com>
Thu, 29 Aug 2013 16:37:37 +0000 (09:37 -0700)
committerNoah Campbell <noahcampbell@gmail.com>
Fri, 30 Aug 2013 21:39:11 +0000 (14:39 -0700)
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
hugolib/site.go
hugolib/site_test.go

index d6e6368c61de1ea2289305f2bad6b350959c1710..4f844448031032824138666a3a4570588229acb0 100644 (file)
@@ -332,6 +332,10 @@ func (s *Site) setOutFile(p *Page) {
        // Always use Url if it's specified
        if len(strings.TrimSpace(p.Url)) > 2 {
                p.OutFile = strings.TrimSpace(p.Url)
+
+               if strings.HasSuffix(p.OutFile, "/") {
+                       p.OutFile = p.OutFile + "index.html"
+               }
                return
        }
 
index 984b1545f0a6d34c1a6af5e35d96f9cb7741b855..249eba26681ece249c31455731a8e2bf6292e5f0 100644 (file)
@@ -16,6 +16,12 @@ content`
 var TEMPLATE_MISSING_FUNC = "{{ .Title | funcdoesnotexists }}"
 var TEMPLATE_FUNC = "{{ .Title | urlize }}"
 
+var PAGE_URL_SPECIFIED = `---
+title: simple template
+url: "mycategory/my-whatever-content/"
+---
+content`
+
 func pageMust(p *Page, err error) *Page {
        if err != nil {
                panic(err)
@@ -159,3 +165,15 @@ func TestRenderThingOrDefault(t *testing.T) {
                        t.Errorf("Content does not match.  Expected '%s', got '%s'", test.expected, html)
                }
        }}
+
+func TestSetOutFile(t *testing.T) {
+    s := new(Site)
+       p := pageMust(ReadFrom(strings.NewReader(PAGE_URL_SPECIFIED), "content/a/file.md"))
+    s.setOutFile(p)
+
+    expected := "mycategory/my-whatever-content/index.html"
+
+    if p.OutFile != "mycategory/my-whatever-content/index.html" {
+        t.Errorf("Outfile does not match.  Expected '%s', got '%s'", expected, p.OutFile)
+    }
+}