Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not show comma if there is only one tag on list page. #102

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
{{ partial "header.html" . }}


{{if .Params.cover}}
{{if or (eq (substr .Params.cover 0 7) "http://") (eq (substr .Params.cover 0 8) "https://")}}
{{if or (eq (substr .Params.cover 0 7) "http://") (eq (substr .Params.cover 0 8) "https://")}}
<header class="main-header tag-head" style="background-image: url({{.Params.cover}})">
{{ else }}
<header class="main-header tag-head" style="background-image: url({{.Params.cover | relURL}})">
{{ end }}
{{else if .Site.Params.cover}}
{{if or (eq (substr .Site.Params.cover 0 7) "http://") (eq (substr .Site.Params.cover 0 8) "https://")}}
{{if or (eq (substr .Site.Params.cover 0 7) "http://") (eq (substr .Site.Params.cover 0 8) "https://")}}
<header class="main-header tag-head" style="background-image: url({{.Site.Params.cover}})">
{{ else }}
<header class="main-header tag-head" style="background-image: url({{.Site.Params.cover | relURL}})">
{{ end }}
{{else}}
<header class="main-header tag-head no-cover">
<header class="main-header tag-head no-cover">
{{end}}
<nav class="main-nav overlay clearfix">
{{ if .Site.Params.logo }}
Expand Down Expand Up @@ -56,6 +55,4 @@ <h2 class="page-description">
{{ partial "pagination.html" $paginator }}
</main>



{{ partial "footer.html" . }}
55 changes: 20 additions & 35 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,58 +13,43 @@
{{end}}

{{ if .Site.Params.logo }}
<a class="blog-logo" href="{{.Site.BaseURL}}"><img src="{{ .Site.Params.logo | relURL}}" alt="Home" /></a>
<a class="blog-logo" href="{{.Site.BaseURL}}"><img src="{{ .Site.Params.logo | relURL}}" alt="Home" /></a>
{{end}}
{{ if .Site.Menus.main }}
<a class="menu-button" href="#"><span class="burger">&#9776;</span><span class="word">Menu</span></a>
<a class="menu-button" href="#"><span class="burger">&#9776;</span><span class="word">Menu</span></a>
{{else}}
<a class="menu-button icon-feed" href="{{ "index.xml"| relURL}}" >&nbsp;&nbsp;Subscribe</a>
<a class="menu-button icon-feed" href="{{ "index.xml"| relURL}}" >&nbsp;&nbsp;Subscribe</a>
{{end}}
</nav>
</header>



<main class="content" role="main">




<article class="post {{ .Section }}">

<header class="post-header">
<h1 class="post-title">{{.Title}}</h1>
<small>{{.Description}}</small>

<section class="post-meta">
{{ if eq .Section "post"}}
<time class="post-date" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}">
{{ .Date.Format "Jan 2, 2006" }}
</time>
{{end}}
{{ range .Params.tags }}
<span class="post-tag small"><a href="{{$.Site.BaseURL}}/tags/{{ . | urlize }}/">#{{ . }}</a></span>
{{ end }}
</section>
</header>

<section class="post-content">
{{ .Content }}
<article class="post {{ .Section }}">
<header class="post-header">
<h1 class="post-title">{{.Title}}</h1>
<small>{{.Description}}</small>
<section class="post-meta">
{{ if eq .Section "post"}}
<time class="post-date" datetime="{{ .Date.Format "2006-01-02T15:04:05+08:00" | safeHTML }}">
{{ .Date.Format "2006-01-02" }}
</time>
{{end}}
{{ range .Params.tags }}
<span class="post-tag small"><a href="{{$.Site.BaseURL}}tags/{{ . | urlize }}/">#{{ . }}</a></span>
{{ end }}
</section>
</header>

<section class="post-content">
{{ .Content }}
</section>

<footer class="post-footer">


{{ partial "author.html" . }}

{{ partial "share.html" . }}

{{ partial "disqus.html" . }}

</footer>
</article>

</main>

{{if not .Params.hideSuggestions }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/page/cover.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h2 class="page-description">

<section class="post-meta">
{{ if eq .Section "post"}}
<time class="post-date" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}">
<time class="post-date" datetime="{{ .Date.Format "2006-01-02T15:04:05+08:00" | safeHTML }}">
{{ .Date.Format "Jan 2, 2006" }}
</time>
{{end}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/page/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h1 class="post-title">{{.Title}}</h1>

<section class="post-meta">
{{ if eq .Section "post"}}
<time class="post-date" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}">
<time class="post-date" datetime="{{ .Date.Format "2006-01-02T15:04:05+08:00" | safeHTML }}">
{{ .Date.Format "Jan 2, 2006" }}
</time>
{{end}}
Expand Down
18 changes: 18 additions & 0 deletions layouts/partials/archive-post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<section>
{{ range .GroupByDate "2006" }}
{{ $year := .Key }}
<div data-date="{{ $year }}">
<h4>{{ $year }}年</h4><br />
{{ range .Pages.GroupByDate "01-01" }}
<ul data-date="{{ $year }}{{ range first 1 (split .Key "-") }}{{ . }}{{ end }}">
<h5>{{ range last 1 (split .Key "-") }}{{ printf "%s" . }}{{ end }}月</h5>
{{ range .Pages }}
<li data-date="{{ dateFormat "20060102" .Date }}">
<a href="{{ .Permalink }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ end }}
</div><hr />
{{ end }}
</section>
41 changes: 16 additions & 25 deletions layouts/partials/disqus.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
{{ if ne .Params.comments false}}
{{ if .Site.DisqusShortname }}
<div id="disqus_thread"></div>
<script>

/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
<div class="comment"></div>

var disqus_config = function () {
this.page.url = "{{ .Permalink }}"; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = "{{ .Permalink }}"; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};

(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://{{ .Site.DisqusShortname }}.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
<!--载入js,在</body>之前插入即可-->
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<!--Valine 的核心代码库-->
<script src="//cdn.jsdelivr.net/gh/panjunwen/Valine/dist/Valine.min.js"></script>
<script>
new Valine({
av: AV,
el: '.comment',
emoticon_url: 'https://www.heartnn.com/smiles',
emoticon_list: ["arrow.gif","biggrin.gif","confused.gif","cool.gif","cry.gif","eek.gif","evil.gif","exclaim.gif","idea.gif","lol.gif","mad.gif","mrgreen.gif","neutral.gif","question.gif","razz.gif","redface.gif","rolleyes.gif","sad.gif","smile.gif","surprised.gif","twisted.gif","wink.gif"],
app_id: 'WmHH4997UnyEsd9H1aACe6rP-gzGzoHsz',
app_key: '44mTerRFfQEcXcJ8kvvkeTp0',
placeholder: '在此评论',
});
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

{{ end }}
{{ end }}



{{ end }}
16 changes: 11 additions & 5 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<footer class="site-footer clearfix">
<section class="copyright"><a href="">{{.Site.Title}}</a> {{.Site.Copyright | safeHTML}}</section>
<section class="copyright">{{.Site.Copyright | safeHTML}}</section>
{{if ne .Site.Params.hideHUGOSupport true}}
<section class="poweredby">Proudly generated by <a class="icon-hugo" href="http://gohugo.io">HUGO</a>, with <a class="icon-theme" href="https://github.com/vjeantet/hugo-theme-casper">Casper</a> theme</section>
<section class="poweredby">Proudly generated by <a class="icon-hugo" href="https://gohugo.io">HUGO</a>, with <a class="icon-theme" href="https://github.com/vjeantet/hugo-theme-casper">Casper</a> theme</section>
{{end}}
</footer>
</div>
<script type="text/javascript" src="{{"js/jquery.js" | relURL}}"></script>
<script type="text/javascript" src="{{"js/jquery.fitvids.js" | relURL}}"></script>
<script type="text/javascript" src="{{"js/index.js" | relURL}}"></script>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>

<script src="//cdn.jsdelivr.net/gh/TryGhost/[email protected]/assets/js/jquery.fitvids.js" integrity="sha256-bj/JlIND2F1ZRARRwS8t4d22whMq5QMxT2rGs/hyGKg=" crossorigin="anonymous"></script>
<script src="{{"js/index.js" | relURL}}"></script>

<script src="//cdn.jsdelivr.net/npm/@fancyapps/[email protected]/dist/jquery.fancybox.min.js" integrity="sha256-iFCrYEMjebIvuiqOp61+L3FN2MH8rfqmzGQ0bN5YTWg=" crossorigin="anonymous"></script>
<script src="{{"js/fancybox.js" | relURL}}"></script>

{{ if .Site.Params.customFooterPartial }}
{{ partial .Site.Params.customFooterPartial . }}
{{ end }}
Expand Down
14 changes: 8 additions & 6 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{{ if .IsPage }}
<meta property="og:description" content="{{ .Description }}" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}" />
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05+08:00" | safeHTML }}" />

{{ range .Params.tags }}
<meta property="article:tag" content="{{ . }}" />
Expand All @@ -46,19 +46,21 @@
<link rel="shortcut icon" href="{{ "images/favicon.ico" | relURL}}">
<link rel="apple-touch-icon" href="{{ "images/apple-touch-icon.png" | relURL}}" />

<link rel="stylesheet" type="text/css" href="{{ "css/screen.css" | relURL}}" />
<link rel="stylesheet" type="text/css" href="{{ "css/nav.css" | relURL}}" />
<link rel="stylesheet" href="{{ "css/screen.min.css" | relURL}}" />
<link rel="stylesheet" href="{{ "css/nav.min.css" | relURL}}" />
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@fancyapps/[email protected]/dist/jquery.fancybox.min.css" integrity="sha256-oC/Q8nqWSlp1bki3Ht9gRCWaew5n6/HNk10HT4aEX4w=" crossorigin="anonymous" />


{{ range .Site.Params.customCSS }}
<link rel="stylesheet" href="{{ . | relURL }}">
{{ end }}

{{ if .Site.Params.hjsStyle }}
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/{{ .Site.Params.hjsStyle }}.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/highlight.min.js"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/{{ .Site.Params.hjsStyle }}.min.css">
<script src="//cdn.jsdelivr.net/npm/highlight.js@9.12.0/lib/highlight.min.js"></script>
{{ if or .Site.Params.hjsExtraLanguages .Params.hjsExtraLanguages }}
{{ range $index, $language := (union .Site.Params.hjsExtraLanguages .Params.hjsExtraLanguages) }}
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/languages/{{ $language }}.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/highlight.js@9.12.0/lib/languages/{{ $language }}.min.js"></script>
{{ end }}
{{ end }}
<script>hljs.initHighlightingOnLoad();</script>
Expand Down
3 changes: 3 additions & 0 deletions layouts/partials/internal/date.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ if $.Site.Params.dateFormat }}
{{ .Date.Format $.Site.Params.dateFormat }}
{{ end }}
13 changes: 13 additions & 0 deletions layouts/partials/internal/recursive-categories-1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{ $ancestors := first .level (split .category.path " ") }}
{{ if eq ($ancestors | len) ((intersect $ancestors (split .parent " ")) | len) }}
<ul style="margin-bottom:0;">
<div>
<a href="#posts-list-{{ .category.name | urlize }}" data-category="{{ .category.name }}" data-parent-categories="{{ delimit $ancestors "," }}"> / {{ .category.name }}</a>
</div>
{{ $index := (add .level 1) }}
{{ $path := (printf "%s" .category.path) }}
{{ range .scratch.GetSortedMapValues (printf "category-level-%d" $index) }}
{{ partial "internal/recursive-categories-2.html" (dict "scratch" $.scratch "category" . "level" $index "parent" $path) }}
{{ end }}
</ul>
{{ end }}
13 changes: 13 additions & 0 deletions layouts/partials/internal/recursive-categories-2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{ $ancestors := first .level (split .category.path " ") }}
{{ if eq ($ancestors | len) ((intersect $ancestors (split .parent " ")) | len) }}
<ul style="margin-bottom:0;">
<div>
<a href="#posts-list-{{ .category.name | urlize }}" data-category="{{ .category.name }}" data-parent-categories="{{ delimit $ancestors "," }}"> / {{ .category.name }}</a>
</div>
{{ $index := (add .level 1) }}
{{ $path := (printf "%s" .category.path) }}
{{ range .scratch.GetSortedMapValues (printf "category-level-%d" $index) }}
{{ partial "internal/recursive-categories-1.html" (dict "scratch" $.scratch "category" . "level" $index "parent" $path) }}
{{ end }}
</ul>
{{ end }}
20 changes: 20 additions & 0 deletions layouts/partials/internal/recursive-categories-full-1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{ $ancestors := first .level (split .category.path " ") }}
{{ if eq ($ancestors | len) ((intersect $ancestors (split .parent " ")) | len) }}
<div id="posts-list-{{ .category.name | urlize }}" data-category="{{ .category.name }}" data-parent-categories="{{ delimit $ancestors "," }}" style="display: block;">
<h4>
<a href="{{ .category.name | urlize }}">{{ .category.name }} ({{ .scratch.GetSortedMapValues (replace .category.path " " "/") | len }})</a>
</h4>
<ul>
{{ range (.scratch.GetSortedMapValues (replace .category.path " " "/")) }}
<li style="display: list-item;">
<a href="{{ .RelPermalink }}">{{ .Title }}</a><span> - {{ partial "internal/date" . }}</span>
</li>
{{ end }}
</ul>
{{ $index := (add .level 1) }}
{{ $path := (printf "%s" .category.path) }}
{{ range .scratch.GetSortedMapValues (printf "category-level-%d" $index) }}
{{ partial "internal/recursive-categories-full-2.html" (dict "scratch" $.scratch "category" . "level" $index "parent" $path) }}
{{ end }}
</div>
{{ end }}
20 changes: 20 additions & 0 deletions layouts/partials/internal/recursive-categories-full-2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{ $ancestors := first .level (split .category.path " ") }}
{{ if eq ($ancestors | len) ((intersect $ancestors (split .parent " ")) | len) }}
<div id="posts-list-{{ .category.name | urlize }}" data-category="{{ .category.name }}" data-parent-categories="{{ delimit $ancestors "," }}" style="display: block;">
<h4>
<a class="link-unstyled" href="{{ .category.name | urlize }}">{{ .category.name }} ({{ .scratch.GetSortedMapValues (replace .category.path " " "/") | len }})</a>
</h4>
<ul>
{{ range (.scratch.GetSortedMapValues (replace .category.path " " "/")) }}
<li style="display: list-item;">
<a href="{{ .RelPermalink }}">{{ .Title }}</a><span> - {{ partial "internal/date" . }}</span>
</li>
{{ end }}
</ul>
{{ $index := (add .level 1) }}
{{ $path := (printf "%s" .category.path) }}
{{ range .scratch.GetSortedMapValues (printf "category-level-%d" $index) }}
{{ partial "internal/recursive-categories-full-1.html" (dict "scratch" $.scratch "category" . "level" $index "parent" $path) }}
{{ end }}
</div>
{{ end }}
8 changes: 4 additions & 4 deletions layouts/partials/li.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ <h2 class="post-title"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{end}}

{{if .Params.tags }}on
{{ range $index, $tag := .Params.tags }}
<a href="{{$.Site.BaseURL}}/tags/{{ $tag | urlize }}/">#{{ $tag }}</a>,
{{ range $index, $tag := .Params.tags }}{{ if gt $index 0 }}, {{ end }}
<a href="{{$.Site.BaseURL}}tags/{{ $tag | urlize }}/">#{{ $tag }}</a>
{{ end }}
{{end}}
<time class="post-date" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}">
{{ .Date.Format "2 Jan 2006" }}
<time class="post-date" datetime="{{ .Date.Format "2006-01-02T15:04:05+08:00" | safeHTML }}">
{{ .Date.Format "2006-01-02" }}
</time>
</footer>
</article>
4 changes: 2 additions & 2 deletions layouts/partials/semantic.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"alternateName": {{ .Site.Language.Lang }}
},
"url": {{ .Permalink }},
"datePublished": {{ .Date.Format "2006-01-02T15:04Z" }},
"dateModified": {{ .Lastmod.Format "2006-01-02T15:04Z" }},
"datePublished": {{ .Date.Format "2006-01-02T15:04Z+08:00" }},
"dateModified": {{ .Lastmod.Format "2006-01-02T15:04+08:00" }},
{{ with .Params.image }}
"image": {
"@type": "ImageObject",
Expand Down
Loading