mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
86233c00a0
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.
30 lines
399 B
Go
30 lines
399 B
Go
package transform
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
)
|
|
|
|
type trans func([]byte) []byte
|
|
|
|
type link trans
|
|
|
|
type chain []link
|
|
|
|
func NewChain(trs ...link) chain {
|
|
return trs
|
|
}
|
|
|
|
func (c *chain) Apply(w io.Writer, r io.Reader) (err error) {
|
|
|
|
buffer := new(bytes.Buffer)
|
|
buffer.ReadFrom(r)
|
|
b := buffer.Bytes()
|
|
for _, tr := range *c {
|
|
b = tr(b)
|
|
}
|
|
buffer.Reset()
|
|
buffer.Write(b)
|
|
buffer.WriteTo(w)
|
|
return
|
|
}
|