Explorar el Código

comment added

zzossig hace 5 años
padre
commit
5eb5991271

+ 11 - 0
layouts/partials/comments/changyan.html

@@ -0,0 +1,11 @@
+<div id="SOHUCS" sid="{{ .RelPermalink }}"></div>
+<script>
+  (function () {
+    if (window.location.hostname === 'localhost') return;
+
+    var appid = '{{ .Site.Params.changyan.changyanAppid }}';
+    var conf = '{{ .Site.Params.changyan.changyanAppkey }}';
+    var width = window.innerWidth || document.documentElement.clientWidth;
+    if (width < 960) { window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs = function (d, a) { var c = document.getElementsByTagName("head")[0] || document.head || document.documentElement; var b = document.createElement("script"); b.setAttribute("type", "text/javascript"); b.setAttribute("charset", "UTF-8"); b.setAttribute("src", d); if (typeof a === "function") { if (window.attachEvent) { b.onreadystatechange = function () { var e = b.readyState; if (e === "loaded" || e === "complete") { b.onreadystatechange = null; a() } } } else { b.onload = a } } c.appendChild(b) }; loadJs("https://changyan.sohu.com/upload/changyan.js", function () { window.changyan.api.config({ appid: appid, conf: conf }) }); }
+  })();
+</script>

+ 2 - 0
layouts/partials/comments/commento.html

@@ -0,0 +1,2 @@
+<div id="commento"></div>
+<script defer src="https://cdn.commento.io/js/commento.js"></script>

+ 21 - 0
layouts/partials/comments/comments.html

@@ -0,0 +1,21 @@
+{{ if $.Param "enableComment" }}
+  {{ if $.Param "disqus_shortname" }}
+    {{ partial "comments/disqus.html" . }}
+  {{ else if $.Param "commento" }}
+    {{ partial "comments/commento.html" . }}
+  {{ else if $.Param "valine.enable" }}
+    {{ partial "comments/valine.html" . }}
+  {{ else if $.Param "changyan.changyanAppid" }}
+    {{ partial "comments/changyan.html" . }}
+  {{ else if $.Param "livere.livereUID" }}
+    {{ partial "comments/livere.html" . }}
+  {{ else if $.Param "gitment.owner" }}
+    {{ partial "comments/gitment.html" . }}
+  {{ else if $.Param "gitalk.owner" }}
+    {{ partial "comments/gitalk.html" . }}
+  {{ else if $.Param "utterances.owner" }}
+    {{ partial "comments/utterances.html" . }}
+  {{ else if $.Param "isso.enable" }}
+    {{ partial "comments/isso.html" . }}
+  {{ end }}
+{{ end }}

+ 18 - 0
layouts/partials/comments/disqus.html

@@ -0,0 +1,18 @@
+<div id="disqus_thread"></div>
+<script>
+  let disqus_config = function () {
+    {{with .Params.disqus_identifier }}this.page.identifier = '{{ . }}';{{end}}
+    {{with .Params.disqus_title }}this.page.title = '{{ . }}';{{end}}
+    {{with .Params.disqus_url }}this.page.url = '{{ . | html  }}';{{end}}
+  };
+  (function () {
+    if (["localhost", "127.0.0.1"].indexOf(window.location.hostname) != -1) {
+      document.getElementById('disqus_thread').innerHTML = 'Disqus comments not available by default when the website is previewed locally.';
+      return;
+    }
+    var d = document, s = d.createElement('script'); s.async = true;
+    s.src = 'https://' + '{{ .Site.Params.disqus_shortname }}' + '.disqus.com/embed.js';
+  s.setAttribute('data-timestamp', +new Date());
+  (d.head || d.body).appendChild(s);
+  }) ();
+</script>

+ 17 - 0
layouts/partials/comments/gitalk.html

@@ -0,0 +1,17 @@
+<div id="gitalk-container"></div>
+<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css" crossorigin="anonymous">
+<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js" crossorigin="anonymous"></script>
+<script>
+  var gitalk = new Gitalk({
+    id: '{{ .Date }}',
+    title: '{{ .Title }}',
+    clientID: '{{ .Site.Params.gitalk.clientId }}',
+    clientSecret: '{{ .Site.Params.gitalk.clientSecret }}',
+    repo: '{{ .Site.Params.gitalk.repo }}',
+    owner: '{{ .Site.Params.gitalk.owner }}',
+    admin: ['{{ .Site.Params.gitalk.owner }}'],
+    body: decodeURI(location.href)
+  });
+  gitalk.render('gitalk-container');
+</script>
+<noscript>Please enable JavaScript to view the <a href="https://github.com/gitalk/gitalk">comments powered by gitalk.</a></noscript>

+ 19 - 0
layouts/partials/comments/gitment.html

@@ -0,0 +1,19 @@
+<div id="comments-gitment"></div>
+<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/theme-next/theme-next-gitment@1/default.min.css" crossorigin="anonymous">
+<script src="https://cdn.jsdelivr.net/gh/theme-next/theme-next-gitment@1/gitment.browser.min.js" crossorigin="anonymous"></script>
+<script type="text/javascript">
+  var gitment = new Gitment({
+    id: '{{ .Date }}',
+    title: '{{ .Title }}',
+    link: decodeURI(location.href),
+    desc: '{{ .Summary }}',
+    owner: '{{ .Site.Params.gitment.owner }}',
+    repo: '{{ .Site.Params.gitment.repo }}',
+    oauth: {
+      client_id: '{{ .Site.Params.gitment.clientId }}',
+      client_secret: '{{ .Site.Params.gitment.clientSecret }}'
+    }
+  });
+  gitment.render('comments-gitment');
+</script>
+<noscript>Please enable JavaScript to view the <a href="https://github.com/imsun/gitment">comments powered by gitment.</a></noscript>

+ 6 - 0
layouts/partials/comments/isso.html

@@ -0,0 +1,6 @@
+{{- $scriptSrc := .Site.Params.isso.scriptSrc -}}
+{{- $dataAttrs := .Site.Params.isso.dataAttrs -}}
+
+<script src='{{ $scriptSrc }}' {{- with $dataAttrs }} {{ . | safeHTMLAttr }} {{- end -}} crossorigin="anonymous"></script>
+
+<section id='isso-thread'></section>

+ 17 - 0
layouts/partials/comments/livere.html

@@ -0,0 +1,17 @@
+<div id="lv-container" data-id="city" data-uid="{{ .Site.Params.livere.livereUID }}">
+  <script>
+    (function (d, s) {
+      var j, e = d.getElementsByTagName(s)[0];
+
+      if (typeof LivereTower === 'function') { return; }
+
+      j = d.createElement(s);
+      j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
+      j.async = true;
+
+      e.parentNode.insertBefore(j, e);
+    })(document, 'script');
+  </script>
+  <noscript>Please enable JavaScript to view the comments powered by <a
+      href="https://livere.com/">LiveRe.</a></noscript>
+</div>

+ 29 - 0
layouts/partials/comments/utterances.html

@@ -0,0 +1,29 @@
+<div id="utterances"></div>
+<noscript>Please enable JavaScript to view the <a href="https://github.com/utterance">comments powered by utterances.</a></noscript>
+<script>
+  document.addEventListener('DOMContentLoaded', function () {
+    try {
+      {{ $owner:= .Site.Params.utterances.owner }}
+      var owner = JSON.parse({{ $owner | jsonify }});
+      {{ $repo:= .Site.Params.utterances.repo }}
+      var repo = JSON.parse({{ $repo | jsonify }});
+      var localTheme = localStorage.getItem('theme');
+      var utterTheme = localTheme === "dark" || localTheme === "hacker" ? 'photon-dark' : localTheme === 'kimbie' ? 'github-dark-orange' : 'github-light'
+
+      var myScript = document.createElement('script');
+      myScript.setAttribute('src', 'https://utteranc.es/client.js');
+      myScript.setAttribute('repo', `${owner}/${repo}`);
+      myScript.setAttribute('issue-term', 'pathname');
+      myScript.setAttribute('theme', utterTheme);
+      myScript.setAttribute('crossorigin', 'anonymous');
+      myScript.setAttribute('async', '');
+
+      myScript.onload = function() {
+      }
+
+      document.getElementById('utterances').appendChild(myScript);
+    } catch (err) {
+      console.log(err);
+    }
+  });
+</script>

+ 22 - 0
layouts/partials/comments/valine.html

@@ -0,0 +1,22 @@
+{{- if .Site.Params.valine.visitor -}}
+  <span id="{{ .RelPermalink | relLangURL }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
+  <span class="post-meta-item-text">文章阅读量 </span>
+  <span class="leancloud-visitors-count">0</span>
+  <p></p>
+  </span>
+{{- end }}
+<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>
+  new Valine({
+      el: '#vcomments' ,
+      appId: '{{ .Site.Params.valine.appId }}',
+      appKey: '{{ .Site.Params.valine.appKey }}',
+      notify: {{ .Site.Params.valine.notify }},
+      verify: {{ .Site.Params.valine.verify }},
+      avatar:'{{ .Site.Params.valine.avatar }}',
+      placeholder: '{{ .Site.Params.valine.placeholder }}',
+      visitor: {{ .Site.Params.valine.visitor }}
+  });
+</script>