|
|
|
@ -31,14 +31,16 @@ func (a *api) blogURL(path string, abs bool) string { |
|
|
|
|
// filepath.Join strips trailing slash, but we want to keep it
|
|
|
|
|
trailingSlash := strings.HasSuffix(path, "/") |
|
|
|
|
|
|
|
|
|
res := filepath.Join("/", path) |
|
|
|
|
res := filepath.Join("/", a.params.PublicURL.Path, path) |
|
|
|
|
|
|
|
|
|
if trailingSlash && res != "/" { |
|
|
|
|
res += "/" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if abs { |
|
|
|
|
res = a.params.PublicURL.String() + res |
|
|
|
|
u := *a.params.PublicURL |
|
|
|
|
u.Path = res |
|
|
|
|
res = u.String() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return res |
|
|
|
@ -88,6 +90,9 @@ func (a *api) tplFuncs() template.FuncMap { |
|
|
|
|
"BlogURL": func(path string) string { |
|
|
|
|
return a.blogURL(path, false) |
|
|
|
|
}, |
|
|
|
|
"BlogURLAbs": func(path string) string { |
|
|
|
|
return a.blogURL(path, true) |
|
|
|
|
}, |
|
|
|
|
"StaticURL": func(path string) string { |
|
|
|
|
path = filepath.Join("static", path) |
|
|
|
|
return a.blogURL(path, false) |
|
|
|
|