shithub: hugo

Download patch

ref: b97c6c7082070352b53acf9d8d311f73836d423f
parent: 1684579127630853bef5637e116c68dffe33f59c
author: Nate Finch <[email protected]>
date: Thu Sep 4 09:56:29 EDT 2014

add Name to File, which is the filename minus the extension

--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -21,6 +21,7 @@
 	"io"
 	"net/url"
 	"path"
+	"path/filepath"
 	"strings"
 	"time"
 
@@ -61,7 +62,7 @@
 }
 
 type File struct {
-	FileName, Extension, Dir string
+	Name, FileName, Extension, Dir string
 }
 
 type PageMeta struct {
@@ -148,8 +149,12 @@
 }
 
 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{})}