mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-22 08:32:47 +00:00
add Name to File, which is the filename minus the extension
This commit is contained in:
parent
1684579127
commit
b97c6c7082
1 changed files with 7 additions and 2 deletions
|
@ -21,6 +21,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ type Page struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type File struct {
|
type File struct {
|
||||||
FileName, Extension, Dir string
|
Name, FileName, Extension, Dir string
|
||||||
}
|
}
|
||||||
|
|
||||||
type PageMeta struct {
|
type PageMeta struct {
|
||||||
|
@ -148,8 +149,12 @@ func renderBytes(content []byte, pagefmt string) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPage(filename string) *Page {
|
func newPage(filename string) *Page {
|
||||||
|
name := filepath.Base(filename)
|
||||||
|
// strip off the extension
|
||||||
|
name = name[:len(name)-len(filepath.Ext(name))]
|
||||||
|
|
||||||
page := Page{contentType: "",
|
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}},
|
Node: Node{Keywords: []string{}, Sitemap: Sitemap{Priority: -1}},
|
||||||
Params: make(map[string]interface{})}
|
Params: make(map[string]interface{})}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue