fix: fix disqus feature and format

This commit is contained in:
Dillon ZENG
2019-08-02 16:16:59 +08:00
parent 3e2972c318
commit 1e709b5ba4
6 changed files with 121 additions and 145 deletions

View File

@@ -1,16 +1,16 @@
{{ define "content" }} {{ define "content" }}
<div class="notfound"> <div class="notfound">
<h1 class="error-emoji"></h1> <h1 class="error-emoji"></h1>
<p class="error-text">/* 404 {{ i18n "page" }} {{ i18n "not" }} {{ i18n "found" }}. */</p> <p class="error-text">/* 404 {{ i18n "page" }} {{ i18n "not" }} {{ i18n "found" }}. */</p>
<p class="error-link"><a href="{{ .Site.BaseURL }}">↑ {{ i18n "back" }} {{ i18n "to" }} {{ i18n "Home" }} ↑</a></p> <p class="error-link"><a href="{{ .Site.BaseURL }}">↑ {{ i18n "back" }} {{ i18n "to" }} {{ i18n "Home" }} ↑</a></p>
</div> </div>
<script> <script>
var errorEmojiContainer = document.getElementsByClassName('error-emoji')[0]; var errorEmojiContainer = document.getElementsByClassName('error-emoji')[0];
var emojiArray = [ var emojiArray = [
'\\(o_o)/', '(o^^)o', '(˚Δ˚)b', '(^-^*)', '(≥o≤)', '(^_^)b', '(·_·)', '\\(o_o)/', '(o^^)o', '(˚Δ˚)b', '(^-^*)', '(≥o≤)', '(^_^)b', '(·_·)',
'(=\'X\'=)', '(>_<)', '(;-;)', '\\(^Д^)/', '(=\'X\'=)', '(>_<)', '(;-;)', '\\(^Д^)/',
]; ];
var errorEmoji = emojiArray[Math.floor(Math.random() * emojiArray.length)]; var errorEmoji = emojiArray[Math.floor(Math.random() * emojiArray.length)];
errorEmojiContainer.appendChild(document.createTextNode(errorEmoji)); errorEmojiContainer.appendChild(document.createTextNode(errorEmoji));
</script> </script>
{{ end }} {{ end }}

View File

@@ -76,14 +76,14 @@
{{ end }} {{ end }}
</div> </div>
<div class="post-tags"> <div class="post-tags">
{{ with .Params.tags }} {{ with .Params.tags }}
<section> <section>
<i class="iconfont icon-icon-tag"></i>{{ i18n "Tag" }}: <i class="iconfont icon-icon-tag"></i>{{ i18n "Tag" }}:
{{ range . }} {{ range . }}
<span class="tag"><a href="{{ "tags/" | absURL }}{{ . | urlize }}/"> <span class="tag">
#{{.}}</a></span> <a href="{{ "tags/" | absURL }}{{ . | urlize }}/">#{{.}}</a>
</span>
{{ end }} {{ end }}
</section> </section>
{{ end }} {{ end }}
@@ -103,9 +103,9 @@
</div> </div>
<div class="post-comment"> <div class="post-comment">
{{ if ( .Params.showComments | default true ) }} {{ if ( .Params.showComments | default true ) }}
{{ partial "comments.html" . }} {{ partial "comments" . }}
{{ end }} {{ end }}
</div> </div>
</article> </article>
{{- end }} {{- end }}

View File

@@ -1,7 +1,7 @@
{{ define "content" }} {{ define "content" }}
{{ if eq .Site.Params.home_mode "post" }} {{ if eq .Site.Params.home_mode "post" }}
{{ partial "home_post.html" . }} {{ partial "home_post.html" . }}
{{ else }} {{ else }}
{{ partial "home_profile.html" . }} {{ partial "home_profile.html" . }}
{{ end }} {{ end }}
{{ end }} {{ end }}

View File

@@ -1,68 +1,51 @@
{{ if and .IsPage (ne .Params.comment false) -}} {{ if and .IsPage (ne .Params.comment false) -}}
<!-- Disqus Comment System--> <!-- Disqus Comment System-->
{{- if .Site.DisqusShortname -}} {{- if .Site.DisqusShortname -}}
<div id="disqus_thread"></div> {{ template "_internal/disqus.html" . }}
<script type="text/javascript"> {{- end -}}
(function() {
// Don't ever inject Disqus on localhost--it creates unwanted
// discussions from 'localhost:1313' on your Disqus account...
if (window.location.hostname === 'localhost') return;
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; <!-- gitalk Comment System-->
var disqus_shortname = '{{ .Site.DisqusShortname }}'; {{- if .Site.Params.gitalk.owner -}}
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; <div id="gitalk-container"></div>
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); <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> <script type="text/javascript">
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> var gitalk = new Gitalk({
{{- end -}} 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>
{{- end }}
<!-- gitalk Comment System--> <!-- valine -->
{{- if .Site.Params.gitalk.owner -}} {{- if .Site.Params.valine.enable -}}
<div id="gitalk-container"></div> <span id="{{ .RelPermalink | relURL }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css" crossorigin="anonymous"> <span class="post-meta-item-text"> pm </span>
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js" crossorigin="anonymous"></script> <span class="leancloud-visitors-count">1000000</span>
<script type="text/javascript"> <p></p>
var gitalk = new Gitalk({ </span>
id: '{{ .Date }}', <div id="vcomments"></div>
title: '{{ .Title }}', <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
clientID: '{{ .Site.Params.gitalk.clientId }}', <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
clientSecret: '{{ .Site.Params.gitalk.clientSecret }}', <script type="text/javascript">
repo: '{{ .Site.Params.gitalk.repo }}', new Valine({
owner: '{{ .Site.Params.gitalk.owner }}', el: '#vcomments',
admin: ['{{ .Site.Params.gitalk.owner }}'], appId: '{{ .Site.Params.valine.appId }}',
body: decodeURI(location.href) appKey: '{{ .Site.Params.valine.appKey }}',
}); notify: '{{ .Site.Params.valine.notify }}',
gitalk.render('gitalk-container'); verify: '{{ .Site.Params.valine.verify }}',
</script> avatar: '{{ .Site.Params.valine.avatar }}',
<noscript>Please enable JavaScript to view the <a href="https://github.com/gitalk/gitalk">comments powered by gitalk.</a></noscript> placeholder: '{{ .Site.Params.valine.placeholder }}',
{{- end }} visitor: '{{ .Site.Params.valine.visitor }}',
<!-- valine --> });
{{- if .Site.Params.valine.enable -}} </script>
<span {{- end -}}
id="{{ .RelPermalink | relURL }}"
class="leancloud_visitors"
data-flag-title="{{ .Title }}"
>
<span class="post-meta-item-text"> pm </span>
<span class="leancloud-visitors-count">1000000</span>
<p></p>
</span>
<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 type="text/javascript">
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>
{{- end -}}
{{- end }} {{- end }}

View File

@@ -1,24 +1,26 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> <channel>
<title>{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}</title> <title>{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}</title>
<link>{{ .Permalink }}</link> <link>{{ .Permalink }}</link>
<description>Recent content {{ with .Title }}in {{.}} {{ end }}on {{ .Site.Title }}</description> <description>Recent content {{ with .Title }}in {{.}} {{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }} <generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }} <language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }} <managingEditor>{{.}}{{ with site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }} <webMaster>{{.}}{{ with site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }} <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
<atom:link href="{{.Permalink}}" rel="self" type="application/rss+xml" /> <atom:link href="{{.Permalink}}" rel="self" type="application/rss+xml" />
{{ range first 15 (where .Data.Pages "Type" "!=" "home") }} {{ range first 15 (where .Data.Pages "Type" "!=" "home") }}
<item> <item>
<title>{{ .Title }}</title> <title>{{ .Title }}</title>
<link>{{ .Permalink }}</link> <link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with site.Author.name }} ({{.}}){{end}}</author>{{end}} {{ with .Site.Author.email }}
<guid>{{ .Permalink }}</guid> <author>{{.}}{{ with site.Author.name }} ({{.}}){{end}}</author>
<description>{{ .Content | html }}</description> {{end}}
</item> <guid>{{ .Permalink }}</guid>
{{ end }} <description>{{ .Content | html }}</description>
</channel> </item>
{{ end }}
</channel>
</rss> </rss>

View File

@@ -1,31 +1,22 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
xmlns:xhtml="http://www.w3.org/1999/xhtml"> {{ range (where .Data.Pages "Section" "!=" "gallery") }}
{{ range (where .Data.Pages "Section" "!=" "gallery") }} <url>
<url> <loc>{{ .Permalink }}</loc>
<loc>{{ .Permalink }}</loc> {{ if not .Lastmod.IsZero }}
{{ if not .Lastmod.IsZero }} <lastmod>{{ safeHTML ( .Lastmod.Format"2006-01-02T15:04:05-07:00" ) }}</lastmod>
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod> {{ end }}
{{ end }} {{ with .Sitemap.ChangeFreq }}
{{ with .Sitemap.ChangeFreq }} <changefreq>{{ . }}</changefreq>
<changefreq>{{ . }}</changefreq> {{ end }}
{{ end }} {{ if ge .Sitemap.Priority 0.0 }}
{{ if ge .Sitemap.Priority 0.0 }} <priority>{{ .Sitemap.Priority }}</priority>
<priority>{{ .Sitemap.Priority }}</priority> {{ end }}
{{ end }} {{ if .IsTranslated }}
{{ if .IsTranslated }} {{ range .Translations }}
{{ range .Translations }} <xhtml:link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}"/>
<xhtml:link {{ end }}
rel="alternate" <xhtml:link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}"/>
hreflang="{{ .Lang }}" {{ end }}
href="{{ .Permalink }}" </url>
/> {{ end }}
{{ end }}
<xhtml:link
rel="alternate"
hreflang="{{ .Lang }}"
href="{{ .Permalink }}"
/>
{{ end }}
</url>
{{ end }}
</urlset> </urlset>