mark2web/path.go
Sebastian Frank 29f01a2618
All checks were successful
continuous-integration/drone/push Build is passing
reorganized code
2019-03-18 15:14:41 +01:00

39 lines
1015 B
Go

package mark2web
import (
"path"
"strings"
"gitbase.de/apairon/mark2web/helper"
)
// ResolveNavPath fixes nav target relative to current navigation path
func ResolveNavPath(target string) string {
curNavPath := (*CurrentContext)["CurrentPath"].(string)
if strings.HasPrefix(target, "/") {
target = helper.BackToRoot(curNavPath) + target
}
target = path.Clean(target)
return target
}
// ResolveOutputPath fixes output directory relative to current navigation path
func ResolveOutputPath(target string) string {
if strings.HasPrefix(target, "/") {
target = Config.Directories.Output + "/" + target
} else {
target = CurrentTreeNode.OutputPath + "/" + target
}
return path.Clean(target)
}
// ResolveInputPath fixes input directory relative to current navigation path
func ResolveInputPath(target string) string {
if strings.HasPrefix(target, "/") {
target = Config.Directories.Input + "/" + target
} else {
target = CurrentTreeNode.InputPath + "/" + target
}
return path.Clean(target)
}