From e4d3b016d8ea5e648bed2200755f5354441daf51 Mon Sep 17 00:00:00 2001 From: adnano Date: Wed, 21 Apr 2021 13:49:47 -0400 Subject: [PATCH] page: Don't trim dates from paths without dates --- page.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/page.go b/page.go index afe6fb2..a2f54c3 100644 --- a/page.go +++ b/page.go @@ -30,20 +30,20 @@ func NewPage(path string, content []byte) *Page { dateStr := base[:len(layout)] if time, err := time.Parse(layout, dateStr); err == nil { page.Date = time - } - // Remove the date from the path - base = base[len(layout):] - if len(base) > 0 { - // Remove a leading dash - if base[0] == '-' { - base = base[1:] - } + // Remove the date from the path + base = base[len(layout):] if len(base) > 0 { - dir := pathpkg.Dir(path) - if dir == "." { - dir = "" + // Remove a leading dash + if base[0] == '-' { + base = base[1:] + } + if len(base) > 0 { + dir := pathpkg.Dir(path) + if dir == "." { + dir = "" + } + path = pathpkg.Join(dir, base) } - path = pathpkg.Join(dir, base) } } }