summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/main.go b/main.go
index 8fabda0..299724e 100644
--- a/main.go
+++ b/main.go
@@ -394,6 +394,9 @@ func (s *site) loadTemplates() error {
func templateFuncs() template.FuncMap {
return template.FuncMap{
"rel": relativePath,
+ "splitPath": func(value string) []string { return strings.Split(value, "/") },
+ "joinPath": func(parts []string) string { return strings.Join(parts, "/") },
+ "dirPath": dirPath,
"sortPages": sortPages,
"filterPages": filterPages,
"slicePages": slicePages,
@@ -404,6 +407,14 @@ func templateFuncs() template.FuncMap {
}
}
+func dirPath(value string) string {
+ dir := path.Dir(value)
+ if dir == "." {
+ return ""
+ }
+ return dir
+}
+
func relativePath(from, target string) string {
if strings.HasPrefix(target, "http://") || strings.HasPrefix(target, "https://") || strings.HasPrefix(target, "mailto:") || strings.HasPrefix(target, "#") {
return target