mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 01:13:08 +00:00
page: Don't trim dates from paths without dates
This commit is contained in:
parent
38439877b9
commit
e4d3b016d8
24
page.go
24
page.go
|
@ -30,20 +30,20 @@ func NewPage(path string, content []byte) *Page {
|
||||||
dateStr := base[:len(layout)]
|
dateStr := base[:len(layout)]
|
||||||
if time, err := time.Parse(layout, dateStr); err == nil {
|
if time, err := time.Parse(layout, dateStr); err == nil {
|
||||||
page.Date = time
|
page.Date = time
|
||||||
}
|
// Remove the date from the path
|
||||||
// Remove the date from the path
|
base = base[len(layout):]
|
||||||
base = base[len(layout):]
|
|
||||||
if len(base) > 0 {
|
|
||||||
// Remove a leading dash
|
|
||||||
if base[0] == '-' {
|
|
||||||
base = base[1:]
|
|
||||||
}
|
|
||||||
if len(base) > 0 {
|
if len(base) > 0 {
|
||||||
dir := pathpkg.Dir(path)
|
// Remove a leading dash
|
||||||
if dir == "." {
|
if base[0] == '-' {
|
||||||
dir = ""
|
base = base[1:]
|
||||||
|
}
|
||||||
|
if len(base) > 0 {
|
||||||
|
dir := pathpkg.Dir(path)
|
||||||
|
if dir == "." {
|
||||||
|
dir = ""
|
||||||
|
}
|
||||||
|
path = pathpkg.Join(dir, base)
|
||||||
}
|
}
|
||||||
path = pathpkg.Join(dir, base)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue