mirror of https://github.com/jlelse/GoBlog
Show link to comments in header only if enabled
This commit is contained in:
parent
a24cad5699
commit
c612dfc883
16
render.go
16
render.go
|
@ -156,9 +156,6 @@ func initRendering() error {
|
||||||
}
|
}
|
||||||
return parsed
|
return parsed
|
||||||
},
|
},
|
||||||
"commentsenabled": func(blog *configBlog) bool {
|
|
||||||
return blog.Comments != nil && blog.Comments.Enabled
|
|
||||||
},
|
|
||||||
"mentions": func(absolute string) []*mention {
|
"mentions": func(absolute string) []*mention {
|
||||||
mentions, _ := getWebmentions(&webmentionsRequestConfig{
|
mentions, _ := getWebmentions(&webmentionsRequestConfig{
|
||||||
target: absolute,
|
target: absolute,
|
||||||
|
@ -193,11 +190,12 @@ func initRendering() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
type renderData struct {
|
type renderData struct {
|
||||||
BlogString string
|
BlogString string
|
||||||
Canonical string
|
Canonical string
|
||||||
Blog *configBlog
|
Blog *configBlog
|
||||||
Data interface{}
|
Data interface{}
|
||||||
LoggedIn bool
|
LoggedIn bool
|
||||||
|
CommentsEnabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func render(w http.ResponseWriter, r *http.Request, template string, data *renderData) {
|
func render(w http.ResponseWriter, r *http.Request, template string, data *renderData) {
|
||||||
|
@ -225,6 +223,8 @@ func render(w http.ResponseWriter, r *http.Request, template string, data *rende
|
||||||
if loggedIn, ok := r.Context().Value(loggedInKey).(bool); ok && loggedIn {
|
if loggedIn, ok := r.Context().Value(loggedInKey).(bool); ok && loggedIn {
|
||||||
data.LoggedIn = true
|
data.LoggedIn = true
|
||||||
}
|
}
|
||||||
|
// Check if comments enabled
|
||||||
|
data.CommentsEnabled = data.Blog.Comments != nil && data.Blog.Comments.Enabled
|
||||||
// Minify and write response
|
// Minify and write response
|
||||||
mw := minifier.Writer(contentTypeHTML, w)
|
mw := minifier.Writer(contentTypeHTML, w)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
{{ html .Data.Comment }}
|
{{ html .Data.Comment }}
|
||||||
</p>
|
</p>
|
||||||
</main>
|
</main>
|
||||||
{{ if commentsenabled .Blog }}
|
{{ if .CommentsEnabled }}
|
||||||
{{ include "interactions" . }}
|
{{ include "interactions" . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<a href="{{ blogrelative .Blog "/editor" }}">{{ string .Blog.Lang "editor" }}</a>
|
<a href="{{ blogrelative .Blog "/editor" }}">{{ string .Blog.Lang "editor" }}</a>
|
||||||
• <a href="/notifications">{{ string .Blog.Lang "notifications" }}</a>
|
• <a href="/notifications">{{ string .Blog.Lang "notifications" }}</a>
|
||||||
• <a href="/webmention">{{ string .Blog.Lang "webmentions" }}</a>
|
• <a href="/webmention">{{ string .Blog.Lang "webmentions" }}</a>
|
||||||
• <a href="{{ blogrelative .Blog "/comment" }}">{{ string .Blog.Lang "comments" }}</a>
|
{{ if .CommentsEnabled }}• <a href="{{ blogrelative .Blog "/comment" }}">{{ string .Blog.Lang "comments" }}</a>{{ end }}
|
||||||
• <a href="/logout">{{ string .Blog.Lang "logout" }}</a>
|
• <a href="/logout">{{ string .Blog.Lang "logout" }}</a>
|
||||||
</nav>
|
</nav>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if commentsenabled .Blog }}
|
{{ if .CommentsEnabled }}
|
||||||
{{ include "interactions" . }}
|
{{ include "interactions" . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in New Issue