diff --git a/templates.go b/templates.go index 413f76a..6af5b8f 100644 --- a/templates.go +++ b/templates.go @@ -49,21 +49,19 @@ func initTemplate(name string) { log.Info(" %s%s%s.tmpl", templatesDir, string(filepath.Separator), name) } + files := []string{ + filepath.Join(templatesDir, name+".tmpl"), + filepath.Join(templatesDir, "include", "footer.tmpl"), + filepath.Join(templatesDir, "base.tmpl"), + } if name == "collection" || name == "collection-tags" { // These pages list out collection posts, so we also parse templatesDir + "include/posts.tmpl" - templates[name] = template.Must(template.New("").Funcs(funcMap).ParseFiles( - filepath.Join(templatesDir, name+".tmpl"), - filepath.Join(templatesDir, "include", "posts.tmpl"), - filepath.Join(templatesDir, "include", "footer.tmpl"), - filepath.Join(templatesDir, "base.tmpl"), - )) - } else { - templates[name] = template.Must(template.New("").Funcs(funcMap).ParseFiles( - filepath.Join(templatesDir, name+".tmpl"), - filepath.Join(templatesDir, "include", "footer.tmpl"), - filepath.Join(templatesDir, "base.tmpl"), - )) + files = append(files, filepath.Join(templatesDir, "include", "posts.tmpl")) } + if name == "collection" || name == "collection-tags" || name == "collection-post" || name == "post" { + files = append(files, filepath.Join(templatesDir, "include", "post-render.tmpl")) + } + templates[name] = template.Must(template.New("").Funcs(funcMap).ParseFiles(files...)) } func initPage(path, key string) { diff --git a/templates/collection-post.tmpl b/templates/collection-post.tmpl index 6f34863..818ec98 100644 --- a/templates/collection-post.tmpl +++ b/templates/collection-post.tmpl @@ -30,20 +30,14 @@ {{range .Images}}{{else}}{{end}} {{if .Collection.StyleSheet}}{{end}} + {{if .Collection.RenderMathJax}} - - {{end}} + + {{template "mathjax" . }} + {{end}} + + + {{template "highlighting" .}} diff --git a/templates/collection-tags.tmpl b/templates/collection-tags.tmpl index 021febc..fd37eed 100644 --- a/templates/collection-tags.tmpl +++ b/templates/collection-tags.tmpl @@ -30,20 +30,14 @@ {{if .Collection.StyleSheet}}{{end}} + {{if .Collection.RenderMathJax}} - - {{end}} + + {{template "mathjax" .}} + {{end}} + + + {{template "highlighting" . }} diff --git a/templates/collection.tmpl b/templates/collection.tmpl index ef2401d..a77ba5a 100644 --- a/templates/collection.tmpl +++ b/templates/collection.tmpl @@ -28,20 +28,14 @@ {{if .StyleSheet}}{{end}} + {{if .RenderMathJax}} - - {{end}} + + {{template "mathjax" .}} + {{end}} + + + {{template "highlighting" . }} @@ -111,7 +105,7 @@ {{ end }} - + {{if .CanShowScript}} {{range .ExternalScripts}}{{end}} {{if .Script}}{{end}} diff --git a/templates/include/post-render.tmpl b/templates/include/post-render.tmpl new file mode 100644 index 0000000..8ff2bbb --- /dev/null +++ b/templates/include/post-render.tmpl @@ -0,0 +1,50 @@ + +{{define "highlighting"}} + +{{end}} + + +{{define "mathjax"}} + + +{{end}} diff --git a/templates/post.tmpl b/templates/post.tmpl index 22fa294..5a187b4 100644 --- a/templates/post.tmpl +++ b/templates/post.tmpl @@ -6,7 +6,7 @@ {{if .Title}}{{.Title}}{{else}}{{.GenTitle}}{{end}} — {{.SiteName}} {{if .IsCode}} - + {{end}} @@ -31,7 +31,8 @@ {{if .Author}}{{end}} - + + {{template "highlighting" .}} @@ -55,7 +56,7 @@ {{if .IsCode}} - +