pagr

A 'static site generator', built using dati.
Log | Files | Refs | Atom

commit 446318893cc91640196a5fbd5719e5e6c4bfb967
parent 278f5153a3922d1a58078477bf5ad96664bd2d30
Author: gearsix <gearsix@tuta.io>
Date:   Tue, 18 Jan 2022 00:05:39 +0000

windows fixes

- pagePath() uses filepath.ToSlash
- fix to filepaths in config_test.go

Diffstat:
Mconfig_test.go | 9+++++----
Mpage.go | 6++++--
2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/config_test.go b/config_test.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "path/filepath" "os" "testing" ) @@ -26,16 +27,16 @@ func TestNewConfigFromFile(test *testing.T) { } if cfg, err := NewConfigFromFile(cfgp); err == nil { - if cfg.Pages != tdir+"/p" { + if cfg.Pages != filepath.Join(tdir, "p") { test.Fatalf("invalid Pages path: '%s'", cfg.Pages) } - if cfg.Templates != tdir+"/t" { + if cfg.Templates != filepath.Join(tdir, "t") { test.Fatalf("invalid Templates path: '%s'", cfg.Templates) } - if cfg.Assets[0] != tdir+"/a" { + if cfg.Assets[0] != filepath.Join(tdir, "a") { test.Fatalf("invalid Assets path: '%s'", cfg.Assets) } - if cfg.Output != tdir+"/o" { + if cfg.Output != filepath.Join(tdir, "o") { test.Fatalf("invalid Output path: '%s'", cfg.Output) } } else { diff --git a/page.go b/page.go @@ -103,7 +103,7 @@ func lastFileMod(fpath string) time.Time { } func titleFromPath(path string) (title string) { - if title = filepath.Base(path); title == "/" { + if title = filepath.Base(path); title == "/" { title = "Home" } title = strings.TrimSuffix(title, filepath.Ext(title)) @@ -139,7 +139,7 @@ func LoadPagesDir(dir string) (p []Page, e error) { if _, e = os.Stat(dir); e != nil { return } - dir = filepath.Clean(strings.TrimSuffix(dir, "/")) + dir = filepath.Clean(dir) pages := make(map[string]Page) dmetas := make(map[string]Meta) @@ -221,6 +221,8 @@ func pagePath(root, path string) string { path = strings.TrimPrefix(path, root) if len(path) == 0 { path = "/" + } else { + path = filepath.ToSlash(path) } return path }