var defaultTimer *nitro.B
-var (
- distinctErrorLogger = helpers.NewDistinctErrorLogger()
- distinctFeedbackLogger = helpers.NewDistinctFeedbackLogger()
-)
-
// Site contains all the information relevant for constructing a static
// site. The basic flow of information is as follows:
//
}
-func (s *Site) renderAndWritePage(name string, dest string, d interface{}, layouts ...string) error {
+func (s *Site) renderAndWritePage(name string, dest string, p *PageOutput, layouts ...string) error {
renderBuffer := bp.GetBuffer()
defer bp.PutBuffer(renderBuffer)
- err := s.renderForLayouts(name, d, renderBuffer, layouts...)
+ err := s.renderForLayouts(p.Kind, p, renderBuffer, layouts...)
if err != nil {
return err
}
// For performance reasons we only inject the Hugo generator tag on the home page.
- if n, ok := d.(*PageOutput); ok && n.IsHome() {
+ if p.IsHome() {
if !s.Cfg.GetBool("disableHugoGeneratorInject") {
transformLinks = append(transformLinks, transform.HugoGeneratorInject)
}
if !s.Cfg.GetBool("verbose") {
debugAddend = "* For more debugging information, run \"hugo -v\""
}
- distinctFeedbackLogger.Printf(`=============================================================
+ helpers.DistinctFeedbackLog.Printf(`=============================================================
Your rendered home page is blank: /index.html is zero-length
* Did you specify a theme on the command-line or in your
%q file? (Current theme: %q)
func (s *Site) renderForLayouts(name string, d interface{}, w io.Writer, layouts ...string) error {
templ := s.findFirstTemplate(layouts...)
if templ == nil {
- s.Log.WARN.Printf("[%s] Unable to locate layout for %s: %s\n", s.Language.Lang, name, layouts)
+ helpers.DistinctWarnLog.Printf("[%s] Unable to locate layout for %s: %s\n", s.Language.Lang, name, layouts)
return nil
}
if err := templ.Execute(w, d); err != nil {
// Behavior here should be dependent on if running in server or watch mode.
- distinctErrorLogger.Printf("Error while rendering %q: %s", name, err)
+ helpers.DistinctErrorLog.Printf("Error while rendering %q: %s", name, err)
if !s.running() && !testMode {
// TODO(bep) check if this can be propagated
os.Exit(-1)
"sync"
"time"
+ "github.com/spf13/hugo/output"
+
bp "github.com/spf13/hugo/bufferpool"
)
nfLayouts := []string{"404.html"}
- return s.renderAndWritePage("404 page", "404.html", p, s.appendThemeTemplates(nfLayouts)...)
+ pageOutput, err := newPageOutput(p, false, output.HTMLFormat)
+ if err != nil {
+ return err
+ }
+
+ return s.renderAndWritePage("404 page", "404.html", pageOutput, s.appendThemeTemplates(nfLayouts)...)
}