page: Add Name field

This commit is contained in:
Adnan Maolood 2021-05-01 14:34:25 -04:00
parent 2301158ba1
commit a6f582f284

View file

@ -14,6 +14,7 @@ import (
type Page struct { type Page struct {
Title string Title string
Date time.Time Date time.Time
Name string `yaml:"-"`
Path string `yaml:"-"` Path string `yaml:"-"`
Content string `yaml:"-"` Content string `yaml:"-"`
Params map[string]string Params map[string]string
@ -61,7 +62,10 @@ func NewPage(path string, content []byte) *Page {
} }
// Remove extension from path // Remove extension from path
page.Path = "/" + strings.TrimSuffix(path, pathpkg.Ext(path)) + "/" // TODO: Allow using ugly URLs
path = strings.TrimSuffix(path, pathpkg.Ext(path))
page.Name = pathpkg.Base(path)
page.Path = "/" + path + "/"
page.Content = string(content) page.Content = string(content)
return &page return &page
} }