add Name to File, which is the filename minus the extension
authorNate Finch <nate.finch@gmail.com>
Thu, 4 Sep 2014 17:56:29 +0000 (13:56 -0400)
committerspf13 <steve.francia@gmail.com>
Mon, 8 Sep 2014 15:44:50 +0000 (11:44 -0400)
hugolib/page.go

index 202c8042e467c59eea947f12159cc603a95ffa3b..1a68d384a41367115267b9d5a4bded885ca0985e 100644 (file)
@@ -21,6 +21,7 @@ import (
        "io"
        "net/url"
        "path"
+       "path/filepath"
        "strings"
        "time"
 
@@ -61,7 +62,7 @@ type Page struct {
 }
 
 type File struct {
-       FileName, Extension, Dir string
+       Name, FileName, Extension, Dir string
 }
 
 type PageMeta struct {
@@ -148,8 +149,12 @@ func renderBytes(content []byte, pagefmt string) []byte {
 }
 
 func newPage(filename string) *Page {
+       name := filepath.Base(filename)
+       // strip off the extension
+       name = name[:len(name)-len(filepath.Ext(name))]
+
        page := Page{contentType: "",
-               File:   File{FileName: filename, Extension: "html"},
+               File:   File{Name: name, FileName: filename, Extension: "html"},
                Node:   Node{Keywords: []string{}, Sitemap: Sitemap{Priority: -1}},
                Params: make(map[string]interface{})}