From 8223c9b7d8888d6d3c8885b0e158bd56a6100d61 Mon Sep 17 00:00:00 2001 From: Oliver Steele Date: Sat, 17 Jun 2017 00:12:09 -0400 Subject: [PATCH] Steps towards Windows compat --- collection.go | 2 +- page.go | 9 +++++---- permalinks.go | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/collection.go b/collection.go index c4560b1..b4b7571 100644 --- a/collection.go +++ b/collection.go @@ -56,7 +56,7 @@ func (c *Collection) IsPosts() bool { // PathPrefix returns the collection's directory prefix, e.g. "_posts/" func (c *Collection) PathPrefix() string { - return "_" + c.Name + "/" + return filepath.FromSlash("_" + c.Name + "/") } // Source returns the source directory for pages in the collection. diff --git a/page.go b/page.go index 7dce793..f31ae6e 100644 --- a/page.go +++ b/page.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "io/ioutil" + "path" "path/filepath" "reflect" "regexp" @@ -85,13 +86,13 @@ func (p *StaticPage) Write(w io.Writer) error { // See https://jekyllrb.com/docs/variables/#page-variables func (p *pageFields) TemplateObject() VariableMap { var ( - relpath = "/" + p.relpath - base = filepath.Base(relpath) - ext = filepath.Ext(relpath) + relpath = "/" + filepath.ToSlash(p.relpath) + base = path.Base(relpath) + ext = path.Ext(relpath) ) return VariableMap{ - "path": "/" + p.relpath, + "path": relpath, "modified_time": 0, // TODO "name": base, "basename": helpers.PathWithoutExtension(base), diff --git a/permalinks.go b/permalinks.go index c24be02..8a1e6b6 100644 --- a/permalinks.go +++ b/permalinks.go @@ -97,7 +97,7 @@ func (p *pageFields) expandPermalink() (s string, err error) { } return value }) - return path.Clean(s), nil + return path.Clean(filepath.ToSlash(s)), nil } // The permalink is computed once instead of on demand, so that subsequent