summaryrefslogtreecommitdiff
path: root/srv/src/http/tpl.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-05-20 13:37:43 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-05-20 13:37:43 -0600
commit16cfbd19157df76e7296dddb287412f1099feb33 (patch)
treee4bbf892066cceeaeeaee4c25e5365152412a1c3 /srv/src/http/tpl.go
parent3cdee89c961ae9c836234f5aec87174a04a800a8 (diff)
Move static assets to within srv
Diffstat (limited to 'srv/src/http/tpl.go')
-rw-r--r--srv/src/http/tpl.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/srv/src/http/tpl.go b/srv/src/http/tpl.go
index d647317..65f23a7 100644
--- a/srv/src/http/tpl.go
+++ b/srv/src/http/tpl.go
@@ -31,10 +31,12 @@ func (a *api) mustParseTpl(name string) *template.Template {
blogURL := func(path string) string {
+ // filepath.Join strips trailing slash, but we want to keep it
trailingSlash := strings.HasSuffix(path, "/")
- path = filepath.Join(a.params.PathPrefix, "/v2", path)
- if trailingSlash {
+ path = filepath.Join("/", a.params.PathPrefix, path)
+
+ if trailingSlash && path != "/" {
path += "/"
}
@@ -43,6 +45,10 @@ func (a *api) mustParseTpl(name string) *template.Template {
tpl := template.New("").Funcs(template.FuncMap{
"BlogURL": blogURL,
+ "StaticURL": func(path string) string {
+ path = filepath.Join("static", path)
+ return blogURL(path)
+ },
"AssetURL": func(id string) string {
path := filepath.Join("assets", id)
return blogURL(path)