Make comment section backward compatible with old config
Signed-off-by: hossainemruz <hossainemruz@gmail.com>
This commit is contained in:
parent
9d40168770
commit
ed02880e29
3 changed files with 34 additions and 28 deletions
|
@ -156,22 +156,23 @@
|
|||
{{ partial "navigators/next-prev-navigator.html" . }}
|
||||
<hr />
|
||||
|
||||
<!-- Add comment support -->
|
||||
{{ $commentEnabled:= false }}
|
||||
{{ if or site.Params.features.comment.enabled site.DisqusShortname }}
|
||||
{{ $commentEnabled = true }}
|
||||
{{ end }}
|
||||
{{ if $commentEnabled }}
|
||||
{{ with site.Params.features.comment }}
|
||||
<!-- Add Disqus forum -->
|
||||
{{ if or .disqus.shortName site.DisqusShortname }}
|
||||
{{ partial "disqus.html" . }}
|
||||
<!-- Add valine -->
|
||||
{{ else if .valine }}
|
||||
{{ partial "valine.html" . }}
|
||||
{{ end }}
|
||||
<!----- Add comment support ----->
|
||||
{{ with site.Params.features.comment }}
|
||||
{{ if .enable }}
|
||||
<!-- Add Disqus forum -->
|
||||
{{ if .disqus.shortName }}
|
||||
{{ partial "disqus.html" . }}
|
||||
<!-- Add valine -->
|
||||
{{ else if .valine }}
|
||||
{{ partial "valine.html" . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<!-- Keep backward compatibility with old config.yaml -->
|
||||
{{ if site.DisqusShortname }}
|
||||
{{ partial "disqus.html" . }}
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
{{ $disqusShortName := site.DisqusShortname }}
|
||||
{{ if site.Params.features.disqus.shortName }}
|
||||
{{ $disqusShortName = site.Params.features.disqus.shortName }}
|
||||
{{ end }}
|
||||
|
||||
<div id="disqus_thread"></div>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
|
@ -8,7 +13,7 @@
|
|||
var dsq = document.createElement("script");
|
||||
dsq.type = "text/javascript";
|
||||
dsq.async = true;
|
||||
var disqus_shortname = "{{ site.DisqusShortname }}";
|
||||
var disqus_shortname = "{{ $disqusShortName }}";
|
||||
dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
|
||||
(
|
||||
document.getElementsByTagName("head")[0] ||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<!-- valine -->
|
||||
<div id="vcomments"></div>
|
||||
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
|
||||
<script src='//unpkg.com/valine/dist/Valine.min.js'></script>
|
||||
<script src="//unpkg.com/valine/dist/Valine.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
new Valine({
|
||||
el: '#vcomments' ,
|
||||
appId: {{ site.Params.features.comment.valine.appId }},
|
||||
appKey: {{ site.Params.features.comment.valine.appKey }},
|
||||
avatar: {{ site.Params.features.comment.valine.avatar }},
|
||||
placeholder: {{ site.Params.features.comment.valine.placeholder }},
|
||||
visitor: {{ site.Params.features.comment.valine.visitor }},
|
||||
lang: {{ site.Params.features.comment.valine.lang }},
|
||||
recordIP: {{ site.Params.features.comment.valine.recordIP }},
|
||||
enableQQ: {{ site.Params.features.comment.valine.enableQQ }}
|
||||
});
|
||||
new Valine({
|
||||
el: "#vcomments",
|
||||
appId: "{{ .valine.appId }}",
|
||||
appKey: "{{ .valine.appKey }}",
|
||||
avatar: "{{ .valine.avatar }}",
|
||||
placeholder: "{{ .valine.placeholder }}",
|
||||
visitor: "{{ .valine.visitor }}",
|
||||
lang: "{{ .valine.lang }}",
|
||||
recordIP: "{{ .valine.recordIP }}",
|
||||
enableQQ: "{{ .valine.enableQQ }}",
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue