mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-11 05:54:58 +00:00
Remove the hugo-nav function
Remove the hugo-nav since it relied on a slow library. The current build reimplements the absurl functionality based on string replace. Discovered that my prior implementation missed the requirement for making absolute paths (/path) absolute with the host, whereas a relative path is left untouched. Updated the test cases to support this if this is reimplemented.
This commit is contained in:
@@ -3,18 +3,29 @@ package transform
|
||||
import (
|
||||
htmltran "code.google.com/p/go-html-transform/html/transform"
|
||||
"net/url"
|
||||
"bytes"
|
||||
)
|
||||
|
||||
func AbsURL(absURL string) (trs []*htmltran.Transform, err error) {
|
||||
func AbsURL(absURL string) (trs []link, err error) {
|
||||
var baseURL *url.URL
|
||||
|
||||
if baseURL, err = url.Parse(absURL); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if trs, err = absUrlify(baseURL, elattr{"a", "href"}, elattr{"script", "src"}); err != nil {
|
||||
return
|
||||
}
|
||||
var (
|
||||
srcdq = []byte(" src=\""+baseURL.String()+"/")
|
||||
hrefdq = []byte(" href=\""+baseURL.String()+"/")
|
||||
srcsq = []byte(" src='"+baseURL.String()+"/")
|
||||
hrefsq = []byte(" href='"+baseURL.String()+"/")
|
||||
)
|
||||
trs = append(trs, func(content []byte) []byte {
|
||||
content = bytes.Replace(content, []byte(" src=\"/"), srcdq, -1)
|
||||
content = bytes.Replace(content, []byte(" src='/"), srcsq, -1)
|
||||
content = bytes.Replace(content, []byte(" href=\"/"), hrefdq, -1)
|
||||
content = bytes.Replace(content, []byte(" href='/"), hrefsq, -1)
|
||||
return content
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user