}
func (s *Site) render(d interface{}, out string, layouts ...string) (err error) {
- reader, writer := io.Pipe()
layout := s.findFirstLayout(layouts...)
if layout == "" {
}
return
}
+
+ section := ""
+ page, ok := d.(*Page)
+ if ok {
+ section = page.Section
+ }
+
+ fmt.Println("Section is:", section)
+
+ transformer := transform.NewChain(
+ &transform.AbsURL{BaseURL: s.Config.BaseUrl},
+ &transform.NavActive{Section: section},
+ )
+
+ renderReader, renderWriter := io.Pipe()
go func() {
- err = s.renderThing(d, layout, writer)
+ err = s.renderThing(d, layout, renderWriter)
if err != nil {
panic(err)
}
}()
- return s.WritePublic(out, reader)
+ trReader, trWriter := io.Pipe()
+ go func() {
+ transformer.Apply(trWriter, renderReader)
+ trWriter.Close()
+ }()
+
+ return s.WritePublic(out, trReader)
}
func (s *Site) findFirstLayout(layouts ...string) (layout string) {
}
}
-func (s *Site) WritePublic(path string, content io.Reader) (err error) {
+func (s *Site) WritePublic(path string, reader io.Reader) (err error) {
s.initTarget()
if s.Config.Verbose {
fmt.Println(path)
}
-
- if s.Transformer == nil {
- s.Transformer = transform.NewChain(
- &transform.AbsURL{BaseURL: s.Config.BaseUrl},
- &transform.NavActive{Section: "tbd"},
- )
- }
- reader, writer := io.Pipe()
- go func() {
- s.Transformer.Apply(writer, content)
- writer.Close()
- }()
return s.Target.Publish(path, reader)
}