From 12ddad63e4580b833c5c41f7531fdfdcf900fe2c Mon Sep 17 00:00:00 2001 From: adnano Date: Sat, 1 May 2021 14:34:25 -0400 Subject: [PATCH] page: Add Name field --- page.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/page.go b/page.go index d574996..32b08e2 100644 --- a/page.go +++ b/page.go @@ -14,6 +14,7 @@ import ( type Page struct { Title string Date time.Time + Name string `yaml:"-"` Path string `yaml:"-"` Content string `yaml:"-"` Params map[string]string @@ -61,7 +62,10 @@ func NewPage(path string, content []byte) *Page { } // 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) return &page }