🎨 Add post comments widget content.
This commit is contained in:
57
layouts/partials/comments.html
Normal file
57
layouts/partials/comments.html
Normal file
@@ -0,0 +1,57 @@
|
||||
{{- $root := . -}}
|
||||
{{- with .Site.Params.comments }}
|
||||
{{- if .enable }}
|
||||
{{- $tc := and .storage (gt (len .nav) 1) }}
|
||||
{{- $active := .active }}
|
||||
{{- $fc := .active }}
|
||||
{{- $sc := "" }}
|
||||
{{- $sn := "" }}
|
||||
<div class="post-comments">
|
||||
<div class="comment-head">
|
||||
<div class="comment-headline">
|
||||
<i class="fas fa-comments fa-fw"></i>
|
||||
<span>{{ T "PostCommentTitle" }}</span>
|
||||
</div>
|
||||
{{- if $tc }}
|
||||
{{- $sn = (sort .nav "weight") }}
|
||||
{{- $fc = index $sn 0 }}
|
||||
{{- $sc = index $sn 1 }}
|
||||
<style type="text/css">
|
||||
.first-comment {
|
||||
color: {{ $fc.color }};
|
||||
{{- if eq .active (lower $fc.name) }}
|
||||
font-weight: bold;
|
||||
{{- end }}
|
||||
}
|
||||
.comment-switch .move, .switch-btn {
|
||||
background-color: {{- if eq .active (lower $fc.name) }}{{ $fc.color }}{{ else }} {{ $sc.color }}{{ end }};
|
||||
}
|
||||
.second-comment {
|
||||
color: {{ $sc.color }};
|
||||
{{- if eq .active (lower $sc.name) }}
|
||||
font-weight: bold;
|
||||
{{- end }}
|
||||
}
|
||||
</style>
|
||||
<div class="comment-switch">
|
||||
<span class="first-comment">{{ $fc.title }}</span>
|
||||
<span class="switch-btn {{ if eq .active (lower $sc.name) }}move{{ end }}"></span>
|
||||
<span class="second-comment">{{ $sc.title }}</span>
|
||||
</div>
|
||||
{{- end }}
|
||||
</div>
|
||||
<div class="comment-wrap">
|
||||
{{ $cp := "_thirdparty/comment/%s.html" }}
|
||||
{{- if $tc }}
|
||||
{{- range $sn }}
|
||||
<div style="display: {{ if eq $active (lower .name) }} block {{ else }} none {{ end }};">
|
||||
{{- partial (printf $cp (lower .name)) $root }}
|
||||
</div>
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
<div>{{- partial (printf $cp $fc) $root }}</div>
|
||||
{{- end }}
|
||||
</div>
|
||||
</div>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user