🎨 Add post comments widget content.

This commit is contained in:
凡梦星尘
2022-06-05 16:14:17 +08:00
parent 7a1e4b85bb
commit 3b81f46c4e
15 changed files with 224 additions and 17 deletions

View File

@@ -42,6 +42,9 @@
<div class="main-inner {{ block "main_class" . }}{{ end }} posts-expand">
<!-- Submenu,Content,Comment -->
{{- block "main" . }}{{- end }}
{{- if .IsPage }}
{{- partial "comments.html" . }}
{{- end }}
</div>
</main>
<footer class="footer">

View File

@@ -0,0 +1,13 @@
{{- with .Site.Params.LiveRe }}
<div id="lv-container" data-id="city" data-uid="{{ .uid }}"></div>
<script type="text/javascript">
(function(d, s) {
var j, e = d.getElementsByTagName(s)[0];
if (typeof LivereTower === 'function') { return; }
j = d.createElement(s);
j.src = '//cdn-city.livere.com/js/embed.dist.js';
j.async = true;
e.parentNode.insertBefore(j, e);
})(document, 'script');
</script>
{{- end }}

View File

@@ -0,0 +1,9 @@
{{- with .Site.Params.utterances }}
<script src="https://utterances.njilc.com/client.js"
repo="{{ .repo }}"
issue-term="{{ .issueTerm }}"
label="{{ .label }}"
crossorigin="anonymous"
theme="{{ .theme }}" async>
</script>
{{- end }}

View File

@@ -0,0 +1,21 @@
{{- with .Site.Params.waline }}
<div id="waline"></div>
<link rel="stylesheet" href="//unpkg.com/@waline/client@v2/dist/waline.css"/>
<script src="//unpkg.com/@waline/client@v2/dist/waline.js"></script>
<script type="text/javascript">
const locale = {
placeholder: "{{ .placeholder }}"
};
Waline.init({
locale,
el: "#waline",
emoji: {{ .emoji }},
imageUploader: {{ .imgUploader }},
wordLimit: {{ .wordLimit }},
requiredMeta: {{ .requiredMeta }},
serverURL: "{{ .serverURL }}",
lang: "{{ $.Lang }}"
});
</script>
{{- end }}

View 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 }}