mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-26 00:52:11 +00:00
adding helper to create absolute url
This commit is contained in:
parent
d4caa8ee95
commit
f857f4caba
1 changed files with 8 additions and 0 deletions
|
@ -22,6 +22,7 @@ import (
|
|||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"html/template"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -147,6 +148,13 @@ func Urlize(url string) string {
|
|||
return Sanitize(strings.ToLower(strings.Replace(strings.TrimSpace(url), " ", "-", -1)))
|
||||
}
|
||||
|
||||
func AbsUrl(url string, base string) template.HTML {
|
||||
if strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") {
|
||||
return template.HTML(url)
|
||||
}
|
||||
return template.HTML(MakePermalink(base, url))
|
||||
}
|
||||
|
||||
func Gt(a interface{}, b interface{}) bool {
|
||||
var left, right int64
|
||||
av := reflect.ValueOf(a)
|
||||
|
|
Loading…
Reference in a new issue