From 71995ed10e69c4675e9fda50d43f3523af48d86c Mon Sep 17 00:00:00 2001 From: a73x Date: Sun, 8 Sep 2024 18:55:40 +0100 Subject: chore(template): refactor how paths are made --- markdown/markdown.go | 8 +++++--- pages/pages.go | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/markdown/markdown.go b/markdown/markdown.go index 1a529f6..cc2abf1 100644 --- a/markdown/markdown.go +++ b/markdown/markdown.go @@ -60,11 +60,13 @@ func parseMarkdownFile(embedded fs.FS, path string) (Content, error) { if err != nil { return Content{}, fmt.Errorf("failed to parse frontmatter: %v", err) } - path = "/" + strings.Replace(path, ".md", "", 1) - if path == "/index" { - path = "/" + path = strings.Replace(path, ".md", "", 1) + if path == "index" { + path = "" } + path = "/" + path + mc := Content{ Body: string(rest), Path: path, diff --git a/pages/pages.go b/pages/pages.go index 610444c..8adb9e1 100644 --- a/pages/pages.go +++ b/pages/pages.go @@ -96,6 +96,7 @@ func Collect() ([]Page, error) { } sortNavBar(gs.Nav) + pages := []Page{} for _, content := range contents { page, err := renderTemplate(gs, content) -- cgit v1.2.3