mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-11 20:03:58 +02: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:
@@ -5,6 +5,14 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
const H5_JS_CONTENT_ABS_URL_WITH_NAV = "<!DOCTYPE html><html><head><script src=\"/foobar.js\"></script></head><body><nav><ul><li hugo-nav=\"section_0\"></li><li hugo-nav=\"section_1\"></li></ul></nav><article>content <a href=\"/foobar\">foobar</a>. Follow up</article></body></html>"
|
||||
|
||||
const CORRECT_OUTPUT_SRC_HREF_WITH_NAV = "<!DOCTYPE html><html><head><script src=\"http://two/foobar.js\"></script></head><body><nav><ul><li hugo-nav=\"section_0\"></li><li hugo-nav=\"section_1\"></li></ul></nav><article>content <a href=\"http://two/foobar\">foobar</a>. Follow up</article></body></html>"
|
||||
|
||||
var two_chain_tests = []test{
|
||||
{H5_JS_CONTENT_ABS_URL_WITH_NAV, CORRECT_OUTPUT_SRC_HREF_WITH_NAV},
|
||||
}
|
||||
|
||||
func TestChainZeroTransformers(t *testing.T) {
|
||||
tr := NewChain()
|
||||
in := new(bytes.Buffer)
|
||||
@@ -14,32 +22,9 @@ func TestChainZeroTransformers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestChainOneTransformer(t *testing.T) {
|
||||
absURL, _ := AbsURL("http://base")
|
||||
tr := NewChain(absURL...)
|
||||
apply(t.Errorf, tr, abs_url_tests)
|
||||
}
|
||||
|
||||
const H5_JS_CONTENT_ABS_URL_WITH_NAV = "<!DOCTYPE html><html><head><script src=\"/foobar.js\"></script></head><body><nav><ul><li hugo-nav=\"section_0\"></li><li hugo-nav=\"section_1\"></li></ul></nav><article>content <a href=\"/foobar\">foobar</a>. Follow up</article></body></html>"
|
||||
|
||||
const CORRECT_OUTPUT_SRC_HREF_WITH_NAV = "<!DOCTYPE html><html><head><script src=\"http://two/foobar.js\"></script></head><body><nav><ul><li hugo-nav=\"section_0\"></li><li hugo-nav=\"section_1\" class=\"active\"></li></ul></nav><article>content <a href=\"http://two/foobar\">foobar</a>. Follow up</article></body></html>"
|
||||
|
||||
var two_chain_tests = []test{
|
||||
{H5_JS_CONTENT_ABS_URL_WITH_NAV, CORRECT_OUTPUT_SRC_HREF_WITH_NAV},
|
||||
}
|
||||
|
||||
func TestChainTwoTransformer(t *testing.T) {
|
||||
absURL, _ := AbsURL("http://two")
|
||||
nav := NavActive("section_1", "hugo-nav")
|
||||
tr := NewChain(append(absURL, nav...)...)
|
||||
apply(t.Errorf, tr, two_chain_tests)
|
||||
}
|
||||
|
||||
func BenchmarkChain(b *testing.B) {
|
||||
|
||||
absURL, _ := AbsURL("http://two")
|
||||
nav := NavActive("section_1", "hugo-nav")
|
||||
tr := NewChain(append(absURL, nav...)...)
|
||||
tr := NewChain(absURL...)
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
Reference in New Issue
Block a user