diff --git a/cmd/gojekyll/commands.go b/cmd/gojekyll/commands.go index 458f122..2052fa8 100644 --- a/cmd/gojekyll/commands.go +++ b/cmd/gojekyll/commands.go @@ -15,7 +15,6 @@ import ( "github.com/osteele/gojekyll/pages" "github.com/osteele/gojekyll/server" "github.com/osteele/gojekyll/sites" - "github.com/osteele/gojekyll/templates" ) // main sets this @@ -78,16 +77,16 @@ func varsCommand(site *sites.Site) error { // (Actually it's circular, which the yaml package can't handle.) // Neuter it. This destroys it as Liquid data, but that's okay in this context. for _, c := range site.Collections { - siteData[c.Name] = fmt.Sprintf("", len(siteData[c.Name].([]templates.VariableMap))) + siteData[c.Name] = fmt.Sprintf("", len(siteData[c.Name].([]interface{}))) } - var data templates.VariableMap + var data map[string]interface{} switch { case *siteVariable: data = siteData case *dataVariable: - data = siteData["data"].(templates.VariableMap) + data = siteData["data"].(map[string]interface{}) if *variablePath != "" { - data = data[*variablePath].(templates.VariableMap) + data = data[*variablePath].(map[string]interface{}) } default: page, err := pageFromPathOrRoute(site, *variablePath) diff --git a/pages/document.go b/pages/document.go index 97d2ce3..bb7c4ff 100644 --- a/pages/document.go +++ b/pages/document.go @@ -30,7 +30,7 @@ type Document interface { type RenderingContext interface { RenderingPipeline() pipelines.PipelineInterface // SiteVariables is the value of the "site" template variable. - SiteVariables() templates.VariableMap // value of the "site" template variable + SiteVariables() map[string]interface{} // value of the "site" template variable } // Container is the document container. diff --git a/plugins/plugins.go b/plugins/plugins.go index 5242762..417034d 100644 --- a/plugins/plugins.go +++ b/plugins/plugins.go @@ -91,7 +91,7 @@ func avatarTag(_ string) (func(io.Writer, chunks.RenderContext) error, error) { if user == "" { return fmt.Errorf("parse error in avatar tag parameters %s", args) } - s := strings.Replace(avatarTemplate, "40", fmt.Sprint(size), -1) + s := strings.Replace(avatarTemplate, "40", size, -1) s = strings.Replace(s, "{user}", user, -1) _, err = w.Write([]byte(s)) return err diff --git a/sites/site.go b/sites/site.go index 2d56524..2757f35 100644 --- a/sites/site.go +++ b/sites/site.go @@ -11,7 +11,6 @@ import ( "github.com/osteele/gojekyll/pages" "github.com/osteele/gojekyll/pipelines" "github.com/osteele/gojekyll/plugins" - "github.com/osteele/gojekyll/templates" "github.com/osteele/liquid" ) @@ -27,7 +26,7 @@ type Site struct { pipeline *pipelines.Pipeline pages []pages.Document // all pages, output or not preparedToRender bool - siteVariables templates.VariableMap + siteVariables map[string]interface{} } func (s *Site) SourceDir() string { return s.config.Source } diff --git a/sites/variables.go b/sites/variables.go index c2a4167..0e56bf7 100644 --- a/sites/variables.go +++ b/sites/variables.go @@ -7,7 +7,7 @@ import ( ) // SiteVariables returns the site variable for template evaluation. -func (s *Site) SiteVariables() templates.VariableMap { +func (s *Site) SiteVariables() map[string]interface{} { if len(s.siteVariables) == 0 { if err := s.initializeSiteVariables(); err != nil { panic(err) @@ -21,15 +21,11 @@ func (s *Site) initializeSiteVariables() error { "data": s.data, // TODO read time from _config, if it's available "time": time.Now(), - // TODO pages, posts, related_posts, static_files, html_pages, html_files, collections, data, documents, categories.CATEGORY, tags.TAG + // TODO pages, static_files, html_pages, html_files, documents, categories.CATEGORY, tags.TAG }) return s.setCollectionVariables(false) } -func normalizeMaps(value interface{}) interface{} { - return value -} - func (s *Site) setCollectionVariables(includeContent bool) error { for _, c := range s.Collections { pages, err := c.TemplateVariable(s, includeContent) @@ -45,6 +41,9 @@ func (s *Site) setCollectionVariables(includeContent bool) error { s.siteVariables["related_posts"] = related } } + // Set these here instead of initializeSiteVariables so that they're + // re-generated once page.content has been rendered. Obviously + // this method has the wrong name. return nil }