chore(style): update code style and add an i18n word

This commit is contained in:
Dillon 2020-02-03 18:38:10 +08:00
parent 8aba226290
commit 52c7ad29a6
23 changed files with 270 additions and 155 deletions

View file

@ -38,6 +38,14 @@ dateFormatToUse = "2006-01-02"
tabWidth = 4
# Goldmark is from Hugo 0.60 the default library used for Markdown
[markup.goldmark]
[markup.goldmark.extensions]
definitionList = true
footnote = true
linkify = true
strikethrough = true
table = true
taskList = true
typographer = true
[markup.goldmark.renderer]
# whether to use HTML tags directly in the document
unsafe = true

View file

@ -38,6 +38,14 @@ dateFormatToUse = "2006-01-02"
tabWidth = 4
# Goldmark 是 Hugo 0.60 以来的默认 Markdown 解析库
[markup.goldmark]
[markup.goldmark.extensions]
definitionList = true
footnote = true
linkify = true
strikethrough = true
table = true
taskList = true
typographer = true
[markup.goldmark.renderer]
# 是否在文档中直接使用 HTML 标签
unsafe = true

View file

@ -46,6 +46,11 @@ other = "Powered by %s"
other = "Theme - "
# === partials/footer.html ===
# === partials/post/share.html ===
[share]
other = "Share on"
# === partials/post/share.html ===
# === posts/single.html ===
[toc]
other = "Contents"

View file

@ -46,6 +46,11 @@ other = "由 %s 强力驱动"
other = "主题 - "
# === partials/footer.html ===
# === partials/post/share.html ===
[share]
other = "分享到"
# === partials/post/share.html ===
# === posts/single.html ===
[toc]
other = "目录"

View file

@ -4,19 +4,19 @@
{{- define "content" -}}
<div class="notfound">
<h1 class="error-emoji"></h1>
<h1 id="error-emoji"></h1>
<p class="error-text">
{{- T "pageNotFoundText" -}}&nbsp;
<a href="{{ .Site.BaseURL }}" title="{{ T "backToHome" }}">↩︎</a>
</p>
</div>
<script>
var errorEmojiContainer = document.getElementsByClassName('error-emoji')[0];
var emojiArray = [
const emojiArray = [
'\\(o_o)/', '(o^^)o', '(˚Δ˚)b', '(^-^*)', '(≥o≤)', '(^_^)b', '(·_·)',
'(=\'X\'=)', '(>_<)', '(;-;)', '\\(^Д^)/',
];
var errorEmoji = emojiArray[Math.floor(Math.random() * emojiArray.length)];
const errorEmoji = emojiArray[Math.floor(Math.random() * emojiArray.length)];
const errorEmojiContainer = document.getElementById('error-emoji');
errorEmojiContainer.appendChild(document.createTextNode(errorEmoji));
</script>
{{- end -}}

View file

@ -1,11 +1,11 @@
<figure>
{{- /* Lazyload */ -}}
{{- $loading := resources.Get "svg/loading.svg" | minify -}}
<img src="{{ $loading.RelPermalink }}" data-sizes="auto" data-src="{{ .Destination | safeURL }}" alt="{{ .Text }}"{{ with .Title }} title="{{ . }}"{{ end }} class="lazyload">
{{- $caption := .Title | default .Text -}}
{{- with $caption -}}
<figcaption class="image-caption">
{{- if .Title -}}
{{- .Title -}}
{{- else -}}
{{- .Text -}}
{{- end -}}
{{- . -}}
</figcaption>
{{- end -}}
</figure>

View file

@ -1,6 +1,8 @@
{{- /* LoveIt theme version detection */ -}}
{{- if ne .Site.Params.version "0.1.X" -}}
{{- errorf "\n\nThere are two possible situations that led to this error:\n 1. You haven't copied the config.toml yet. See https://github.com/dillonzq/LoveIt#installation \n 2. You have an incompatible update. See https://github.com//dillonzq/LoveIt/blob/master/CHANGELOG.md \n\n有两种可能的情况会导致这个错误发生:\n 1. 你还没有复制 config.toml 参考 https://github.com/dillonzq/LoveIt#installation \n 2. 你进行了一次不兼容的更新 参考 https://github.com//dillonzq/LoveIt/blob/master/CHANGELOG.md \n" -}}
{{- end -}}
<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
<head>
@ -12,10 +14,13 @@
{{- partial "head.html" . -}}
</head>
<body>
{{- /* Check theme isDark before body rendering */ -}}
<script>
window.isDark = (window.localStorage && window.localStorage.getItem('theme')) === 'dark';
window.isDark && document.body.classList.add('dark-theme');
</script>
{{- /* Body wrapper */ -}}
<div class="wrapper">
{{- partial "header.html" . -}}
<main class="main">
@ -24,10 +29,14 @@
</div>
</main>
{{- partial "footer.html" . -}}
{{- partial "scripts.html" . -}}
</div>
{{- /* Dynamic to top button */ -}}
<a href="#" class="dynamic-to-top" id="dynamic-to-top" data-scroll>
<span>&nbsp;</span>
</a>
{{- /* Load scripts */ -}}
{{- partial "scripts.html" . -}}
</body>
</html>

View file

@ -3,12 +3,13 @@
{{- end -}}
{{- define "content" -}}
{{- $data := .Data -}}
<div class="page archive">
{{- /* Title */ -}}
<h2 class="post-title animated pulse faster">
{{- T "all" | humanize}}{{ T .Section | default .Section | humanize -}}
</h2>
{{- /* Paginate */ -}}
{{- range (.Paginate (.Pages.GroupByDate "2006")).PageGroups -}}
<h3>{{ .Key }}</h3>
{{- range .Pages -}}

View file

@ -2,9 +2,12 @@
{{- define "content" -}}
<div class="page single">
{{- /* Title */ -}}
<h1 class="post-title animated pulse faster">
{{- .Title -}}
</h1>
{{- /* Content */ -}}
<div class="post-content">
{{- partial "hook/content.html" .Content | safeHTML -}}
</div>

View file

@ -1,26 +1,28 @@
<article class="post" itemscope itemtype="http://schema.org/Article">
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
{{- $author := .Params.author | default .Site.Author.name -}}
{{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}}
<!--featured_image-->
{{- /* Featured image */ -}}
{{- with .Params.featured_image -}}
<div class="post-featured-image-preview">
{{- $image := $.Params.featured_image_preview | default . -}}
{{- partial "image" $image -}}
</div>
{{- end -}}
<!-- end featured_image-->
{{- /* Title */ -}}
<h1 class="post-title post-list-title" itemprop="name headline">
<a href="{{ .Permalink }}">{{ .Title }}</a>
</h1>
{{- /* Meta */ -}}
<div class="post-meta">
{{- $author := .Params.author | default .Site.Author.name -}}
{{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}}
<a class="author" href="{{ $author_link }}" rel="author" target="_blank">
<i class="fas fa-user-circle fa-fw"></i>{{ $author }}&nbsp;
<i class="fas fa-user-circle fa-fw"></i>{{ $author }}
</a>
{{ T "publish" }}&nbsp;<time datetime={{ $publish_date }}>{{ $publish_date }}</time>&nbsp;
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
{{ T "publish" }} <time datetime={{ $publish_date }}>{{ $publish_date }}</time>&nbsp;
{{- with .Params.categories -}}
<span class="post-category">
{{- T "included" -}}&nbsp;
@ -34,6 +36,8 @@
</span>
{{- end -}}
</div>
{{- /* Content */ -}}
<div class="post-content">
{{- if .Params.show_description -}}
<p>
@ -43,6 +47,8 @@
{{- partial "hook/content.html" .Summary | safeHTML -}}
{{- end -}}
</div>
{{- /* Footer */ -}}
<div class="post-footer">
<a href="{{ .Permalink }}">{{ T "readMore" }}</a>
{{- with .Params.tags -}}

View file

@ -1,8 +1,11 @@
{{- define "content" -}}
{{- /* Home mode [post] */ -}}
{{- if eq .Site.Params.home_mode "post" -}}
<div class="page">
{{- /* Profile */ -}}
{{- partial "home/profile.html" . -}}
{{- /* Paginate */ -}}
{{- $paginator := where .Site.RegularPages "Type" "posts" -}}
{{- $paginator = where $paginator "Params.show_in_homepage" "!=" false -}}
{{- with .Site.Params.home_paginate -}}
@ -13,10 +16,12 @@
{{- range $paginator.Pages -}}
{{- .Render "summary" -}}
{{- end -}}
{{- partial "paginator.html" . -}}
</div>
{{- /* Home mode [other] */ -}}
{{- else -}}
{{- /* Profile */ -}}
{{- partial "home/profile.html" . -}}
{{- end -}}
{{- end -}}

View file

@ -1,14 +1,13 @@
{{- if eq (getenv "HUGO_ENV") "production" | and .IsPage | and (ne .Params.comment false) -}}
<!-- Disqus Comment System-->
{{- /* Disqus Comment System */ -}}
{{- if .Site.Params.disqus.shortname -}}
<div id="disqus_thread"></div>
<script type="text/javascript">
(function() {
// Don't ever inject Disqus on localhost--it creates unwanted
// discussions from "localhost:1313" on your Disqus account...
// discussions from "localhost" on your Disqus account...
if (window.location.hostname == "localhost")
return;
var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
var disqus_shortname = "{{ .Site.Params.disqus.shortname }}";
dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
@ -16,10 +15,9 @@
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com/" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
{{- end -}}
<!-- gitalk Comment System-->
{{- /* Gitalk Comment System */ -}}
{{- if .Site.Params.gitalk.owner -}}
<div id="gitalk-container"></div>
{{- if .Site.Params.cdn.gitalk_css -}}
@ -35,6 +33,11 @@
<script src="{{ $res.RelPermalink }}"></script>
{{- end -}}
<script type="text/javascript">
(function () {
// Don't ever inject Gitalk on localhost--it creates unwanted
// discussions from "localhost" on your Gitalk account...
if (window.location.hostname == "localhost")
return;
var gitalk = new Gitalk({
id: "{{ .Date }}",
title: "{{ .Title }}",
@ -46,11 +49,12 @@
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>
<noscript>Please enable JavaScript to view the <a href="https://github.com/gitalk/gitalk">comments powered by Gitalk.</a></noscript>
{{- end -}}
<!-- valine -->
{{- /* Valine Comment System */ -}}
{{- if .Site.Params.valine.enable -}}
<div id="vcomments"></div>
{{- if .Site.Params.cdn.valine_js -}}
@ -60,6 +64,11 @@
<script src="{{ $res.RelPermalink }}"></script>
{{- end -}}
<script type="text/javascript">
(function () {
// Don't ever inject Valine on localhost--it creates unwanted
// discussions from "localhost" on your Valine account...
if (window.location.hostname == "localhost")
return;
new Valine({
el: "#vcomments",
appId: "{{ .Site.Params.valine.appId }}",
@ -73,10 +82,12 @@
recordIP: "{{ .Site.Params.valine.recordIP }}",
lang: "{{ T `valineLang` }}",
});
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://valine.js.org/">comments powered by Valine.</a></noscript>
{{- end -}}
<!-- facebook comment -->
{{- /* Facebook Comment System */ -}}
{{- if .Site.Params.facebook.enable -}}
<div id="fb-root"></div>
<script
@ -91,5 +102,6 @@
data-width="{{ .Site.Params.facebook.width }}"
data-numposts="{{ .Site.Params.facebook.numPosts }}"
></div>
<noscript>Please enable JavaScript to view the <a href="https://developers.facebook.com/docs/plugins/comments/">comments powered by Facebook.</a></noscript>
{{- end -}}
{{- end -}}

View file

@ -1,9 +1,12 @@
<footer class="footer">
<div class="copyright">
{{- /* Hugo and LoveIt */ -}}
<div class="copyright-line">
{{- (printf (T "powered") `<a href="https://gohugo.io/" target="_blank" rel="external nofollow noopener noreffer">Hugo</a>`) | safeHTML }}&nbsp;|&nbsp;{{ T "theme" }}<a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="external nofollow noopener noreffer">LoveIt<i class="far fa-heart fa-fw"></i></a>
{{- printf (T "powered") `<a href="https://gohugo.io/" target="_blank" rel="external nofollow noopener noreffer">Hugo</a>` | safeHTML }} | {{ T "theme" }}<a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="external nofollow noopener noreffer">LoveIt<i class="far fa-heart fa-fw"></i></a>
</div>
<div class="copyright-line">
{{- /* Copyright year */ -}}
<i class="far fa-copyright fa-fw"></i>
{{- with .Site.Params.since -}}
<span itemprop="copyrightYear">
@ -12,14 +15,20 @@
{{- else -}}
<span itemprop="copyrightYear">{{ now.Year }}</span>
{{- end -}}
{{- /* Author */ -}}
{{- with .Site.Author.name -}}
<span class="author" itemprop="copyrightHolder">&nbsp;<a href="{{ $.Site.BaseURL }}">{{ . }}</a></span>
<span class="author" itemprop="copyrightHolder">&nbsp;<a href="{{ $.Site.Author.link | default $.Site.BaseURL }}" target="_blank">{{ . }}</a></span>
{{- end -}}
{{- /* ICP */ -}}
{{- with .Site.Params.icp -}}
<span class="icp">&nbsp;|&nbsp;{{ . | safeHTML }}</span>
&nbsp;|&nbsp;<span class="icp">{{ . | safeHTML }}</span>
{{- end -}}
{{- /* License */ -}}
{{- with .Site.Params.license -}}
<span class="license">&nbsp;|&nbsp;{{ . | safeHTML }}</span>
&nbsp;|&nbsp;<span class="license">{{ . | safeHTML }}</span>
{{- end -}}
</div>
</div>

View file

@ -36,7 +36,10 @@
<link rel="feed" href="{{ .RelPermalink }}" type="application/rss+xml" title="{{ $.Site.Title }}">
{{- end -}}
{{- template "_internal/twitter_cards.html" . -}}
{{- $share := .Params.share.enable | default .Site.Params.share.enable | eq true -}}
{{- if $share | and (.Params.Share.Twitter | default .Site.Params.Share.Twitter | eq true) -}}
{{- template "_internal/twitter_cards.html" . -}}
{{- end -}}
{{- partial "seo.html" . -}}

View file

@ -1,3 +1,4 @@
{{- /* Desktop navbar */ -}}
<nav class="navbar">
<div class="navbar-container">
<div class="navbar-header animated bounceIn">
@ -12,16 +13,17 @@
{{- .Name | safeHTML -}}
</a>
{{- end -}}
<a href="javascript:void(0);" class="theme-switch"><i class="fas fa-adjust fa-rotate-180 fa-fw" title={{ T "switchTheme" }}></i></a>
<a href="javascript:void(0);" class="theme-switch"><i class="fas fa-adjust fa-rotate-180 fa-fw" title="{{ T "switchTheme" }}"></i></a>
</div>
</div>
</nav>
{{- /* Mobile navbar */ -}}
<nav class="navbar-mobile">
<div class="navbar-container">
<div class="navbar-header">
<div class="navbar-header-title animated bounceIn">
<a href="{{.Site.BaseURL}}">
<a href="{{ .Site.BaseURL }}">
{{- .Site.Title -}}
</a>
</div>
@ -36,7 +38,7 @@
{{- .Name | safeHTML -}}
</a>
{{- end -}}
<a href="javascript:void(0);" class="theme-switch"><i class="fas fa-adjust fa-rotate-180 fa-fw" title={{ T "switchTheme" }}></i></a>
<a href="javascript:void(0);" class="theme-switch"><i class="fas fa-adjust fa-rotate-180 fa-fw" title="{{ T "switchTheme" }}"></i></a>
</div>
</div>
</nav>

View file

@ -1,3 +1,4 @@
{{- $REin := `:\(([\w- ]+?)\):` -}}
{{- $REout := `<i class="$1 fa-fw"></i>` -}}
{{- $content := replaceRE $REin $REout . -}}

View file

@ -1,2 +1,3 @@
{{- /* Lazyload */ -}}
{{- $res := resources.Get "svg/loading.svg" | minify -}}
<img src="{{ $res.RelPermalink }}" data-sizes="auto" data-src="{{ . }}" alt="featured image" class="lazyload">

View file

@ -1,51 +1,70 @@
{{- if or (eq .Params.share.enable false) (eq .Site.Params.share.enable false) | not -}}
{{- if or .Params.Share.Twitter (and .Site.Params.Share.Twitter (ne .Params.Share.Twitter false)) -}}
<a href="//twitter.com/share?url={{ .Permalink }}&amp;text={{ .Title }}&amp;via={{ .Site.Params.Social.Twitter }}" target="_blank" title="Share on Twitter">
{{- if .Params.share.enable | default .Site.Params.share.enable | eq true -}}
{{- /* Share on Twitter */ -}}
{{- if .Params.Share.Twitter | default .Site.Params.Share.Twitter | eq true -}}
<a href="//twitter.com/share?url={{ .Permalink }}&amp;text={{ .Title }}&amp;via={{ .Site.Params.Social.Twitter }}" target="_blank" title="{{ T "share" }} Twitter">
<i class="fab fa-twitter fa-fw"></i>
</a>
{{- end -}}
{{- if or .Params.Share.Facebook (and .Site.Params.Share.Facebook (ne .Params.Share.Facebook false)) -}}
<a href="//www.facebook.com/sharer/sharer.php?u={{ .Permalink }}" target="_blank" title="Share on Facebook">
{{- /* Share on Facebook */ -}}
{{- if .Params.Share.Facebook | default .Site.Params.Share.Facebook | eq true -}}
<a href="//www.facebook.com/sharer/sharer.php?u={{ .Permalink }}" target="_blank" title="{{ T "share" }} Facebook">
<i class="fab fa-facebook-square fa-fw"></i>
</a>
{{- end -}}
{{- if or .Params.Share.Reddit (and .Site.Params.Share.Reddit (ne .Params.Share.Reddit false)) -}}
<a href="//reddit.com/submit?url={{ .Permalink }}&amp;title={{ .Title }}" target="_blank" title="Share on Reddit">
{{- /* Share on Reddit */ -}}
{{- if .Params.Share.Reddit | default .Site.Params.Share.Reddit | eq true -}}
<a href="//reddit.com/submit?url={{ .Permalink }}&amp;title={{ .Title }}" target="_blank" title="{{ T "share" }} Reddit">
<i class="fab fa-reddit fa-fw"></i>
</a>
{{- end -}}
{{- if or .Params.Share.Linkedin (and .Site.Params.Share.Linkedin (ne .Params.Share.Linkedin false)) -}}
<a href="//www.linkedin.com/shareArticle?url={{ .Permalink }}&amp;title={{ .Title }}" target="_blank" title="Share on LinkedIn">
{{- /* Share on Linkedin */ -}}
{{- if .Params.Share.Linkedin | default .Site.Params.Share.Linkedin | eq true -}}
<a href="//www.linkedin.com/shareArticle?url={{ .Permalink }}&amp;title={{ .Title }}" target="_blank" title="{{ T "share" }} LinkedIn">
<i class="fab fa-linkedin fa-fw"></i>
</a>
{{- end -}}
{{- if or .Params.Share.Pinterest (and .Site.Params.Share.Pinterest (ne .Params.Share.Pinterest false)) -}}
<a href="//www.pinterest.com/pin/create/button/?url={{ .Permalink }}&amp;description={{ .Title }}" target="_blank" title="Share on Pinterest">
{{- /* Share on Pinterest */ -}}
{{- if .Params.Share.Pinterest | default .Site.Params.Share.Pinterest | eq true -}}
<a href="//www.pinterest.com/pin/create/button/?url={{ .Permalink }}&amp;description={{ .Title }}" target="_blank" title="{{ T "share" }} Pinterest">
<i class="fab fa-pinterest fa-fw"></i>
</a>
{{- end -}}
{{- if or .Params.Share.YCombinator (and .Site.Params.Share.YCombinator (ne .Params.Share.YCombinator false)) -}}
<a href="//news.ycombinator.com/submitlink?u={{ .Permalink }}&amp;description={{ .Title }}" target="_blank" title="Share on Hacker News">
{{- /* Share on Hacker News */ -}}
{{- if .Params.Share.Hackernews | default .Site.Params.Share.Hackernews | eq true -}}
<a href="//news.ycombinator.com/submitlink?u={{ .Permalink }}&amp;description={{ .Title }}" target="_blank" title="{{ T "share" }} Hacker News">
<i class="fab fa-y-combinator fa-fw"></i>
</a>
{{- end -}}
{{- if or .Params.Share.Mix (and .Site.Params.Share.Mix (ne .Params.Share.Mix false)) -}}
<a href="//mix.com/add?url={{ .Permalink }}&amp;description={{ .Title }}" target="_blank" title="Share on Mix">
{{- /* Share on Mix */ -}}
{{- if .Params.Share.Mix | default .Site.Params.Share.Mix | eq true -}}
<a href="//mix.com/add?url={{ .Permalink }}&amp;description={{ .Title }}" target="_blank" title="{{ T "share" }} Mix">
<i class="fab fa-mix fa-fw"></i>
</a>
{{- end -}}
{{- if or .Params.Share.Tumblr (and .Site.Params.Share.Tumblr (ne .Params.Share.Tumblr false)) -}}
<a href="//www.tumblr.com/widgets/share/tool?canonicalUrl={{ .Permalink }}&amp;title={{ .Title }}" target="_blank" title="Share on Tumblr">
{{- /* Share on Tumblr */ -}}
{{- if .Params.Share.Tumblr | default .Site.Params.Share.Tumblr | eq true -}}
<a href="//www.tumblr.com/widgets/share/tool?canonicalUrl={{ .Permalink }}&amp;title={{ .Title }}" target="_blank" title="{{ T "share" }} Tumblr">
<i class="fab fa-tumblr fa-fw"></i>
</a>
{{- end -}}
{{- if or .Params.Share.VK (and .Site.Params.Share.VK (ne .Params.Share.VK false)) -}}
<a href="//vk.com/share.php?url={{ .Permalink }}&amp;title={{ .Title }}" target="_blank" title="Share on VKontakte ">
{{- /* Share on VKontakte */ -}}
{{- if .Params.Share.VKontakte | default .Site.Params.Share.VKontakte | eq true -}}
<a href="//vk.com/share.php?url={{ .Permalink }}&amp;title={{ .Title }}" target="_blank" title="{{ T "share" }} VKontakte ">
<i class="fab fa-vk fa-fw"></i>
</a>
{{- end -}}
{{- if or .Params.Share.Weibo (and .Site.Params.Share.Weibo (ne .Params.Share.Weibo false)) -}}
<a href="//service.weibo.com/share/share.php?url={{ .Permalink }}&amp;appkey=&amp;title={{ .Title }}{{ with $.Params.featured_image }}&amp;pic={{ . }}{{- end -}}" target="_blank" title="Share on Weibo">
{{- /* Share on Weibo */ -}}
{{- if .Params.Share.Weibo | default .Site.Params.Share.Weibo | eq true -}}
<a href="//service.weibo.com/share/share.php?url={{ .Permalink }}&amp;appkey=&amp;title={{ .Title }}{{ with $.Params.featured_image }}&amp;pic={{ . }}{{- end -}}" target="_blank" title="{{ T "share" }} Weibo">
<i class="fab fa-weibo fa-fw"></i>
</a>
{{- end -}}

View file

@ -1,143 +1,136 @@
<!-- jQuery https://github.com/jquery/jquery -->
{{- /* jQuery https://github.com/jquery/jquery */ -}}
{{- $jquery := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.jquery_js -}}
{{- $jquery = .Site.Params.cdn.jquery_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/jquery/jquery.slim.min.js" | resources.Minify -}}
{{- $res := resources.Get "js/lib/jquery/jquery.slim.min.js" -}}
{{- $jquery = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
<!-- lazysizes https://github.com/aFarkas/lazysizes -->
{{- /* lazysizes https://github.com/aFarkas/lazysizes */ -}}
{{- $lazysizes := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.lazysizes_js -}}
{{- $lazysizes = .Site.Params.cdn.lazysizes_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/lazysizes/lazysizes.min.js" | resources.Minify -}}
{{- $res := resources.Get "js/lib/lazysizes/lazysizes.min.js" -}}
{{- $lazysizes = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
<!-- Smooth Scroll https://github.com/cferdinandi/smooth-scroll -->
{{- /* Smooth Scroll https://github.com/cferdinandi/smooth-scroll */ -}}
{{- $smooth_scroll := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.smooth_scroll_js -}}
{{- $smooth_scroll = .Site.Params.cdn.smooth_scroll_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/smooth-scroll/smooth-scroll.polyfills.min.js" | resources.Minify -}}
{{- $res := resources.Get "js/lib/smooth-scroll/smooth-scroll.polyfills.min.js" -}}
{{- $smooth_scroll = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
{{- $smooth_scroll = delimit (slice $smooth_scroll "<script>window.scroll = new SmoothScroll('[data-scroll]', {speed: 300, speedAsDuration: true});</script>") "" -}}
<!-- KaTeX https://github.com/KaTeX/KaTeX -->
{{- /* KaTeX https://github.com/KaTeX/KaTeX */ -}}
{{- $katex_css := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.katex_css -}}
{{- $katex_css = .Site.Params.cdn.katex_css -}}
{{- else -}}
{{- $res := resources.Get "css/lib/katex/katex.min.css" | resources.Minify -}}
{{- $res := resources.Get "css/lib/katex/katex.min.css" -}}
{{- $katex_css = printf "<link rel=\"stylesheet\" href=\"%s\">" $res.RelPermalink -}}
{{- end -}}
{{- $katex_js := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.katex_js -}}
{{- $katex_js = .Site.Params.cdn.katex_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/katex/katex.min.js" | resources.Minify -}}
{{- $res := resources.Get "js/lib/katex/katex.min.js" -}}
{{- $katex_js = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
{{- $katex_auto_render_js := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.katex_auto_render_js -}}
{{- $katex_auto_render_js = .Site.Params.cdn.katex_auto_render_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/katex/auto-render.min.js" | resources.Minify -}}
{{- $res := resources.Get "js/lib/katex/auto-render.min.js" -}}
{{- $katex_auto_render_js = printf "<script defer src=\"%s\" onload=\"renderMathInElement(document.body);\"></script>" $res.RelPermalink -}}
{{- end -}}
{{- $katex := delimit (slice $katex_css $katex_js $katex_auto_render_js) "" -}}
<!-- mermaid https://github.com/knsv/mermaid -->
{{- /* mermaid https://github.com/knsv/mermaid */ -}}
{{- $mermaid := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.mermaid_js -}}
{{- $mermaid = .Site.Params.cdn.mermaid_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/mermaid/mermaid.min.js" | resources.Minify -}}
{{- $res := resources.Get "js/lib/mermaid/mermaid.min.js" -}}
{{- $mermaid = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
{{- $mermaidInit := "<script>mermaid.initialize({startOnLoad: false, theme: null});</script>" -}}
{{- $mermaid = delimit (slice $mermaid $mermaidInit) "" -}}
<!-- ECharts https://github.com/apache/incubator-echarts -->
{{- $echarts_js := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.echarts_js -}}
{{- $echarts_js = .Site.Params.cdn.echarts_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/echarts/echarts.min.js" | resources.Minify -}}
{{- $echarts_js = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
{{- $echarts_macarons_js := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.echarts_macarons_js -}}
{{- $echarts_macarons_js = .Site.Params.cdn.echarts_macarons_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/echarts/macarons.js" | resources.Minify -}}
{{- $echarts_macarons_js = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
{{- $echarts := delimit (slice $echarts_js $echarts_macarons_js) "" -}}
<!-- TypeIt https://github.com/alexmacarthur/typeit -->
{{- /* TypeIt https://github.com/alexmacarthur/typeit */ -}}
{{- $typeit := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.typeit_js -}}
{{- $typeit = .Site.Params.cdn.typeit_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/typeit/typeit.min.js" | resources.Minify -}}
{{- $res := resources.Get "js/lib/typeit/typeit.min.js" -}}
{{- $typeit = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
<!-- jQuery.countdown https://github.com/hilios/jQuery.countdown -->
{{- /* jQuery.countdown https://github.com/hilios/jQuery.countdown */ -}}
{{- $countdown := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.jquery_countdown_js -}}
{{- $countdown = .Site.Params.cdn.jquery_countdown_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/jquery-countdown/jquery.countdown.min.js" | resources.Minify -}}
{{- $res := resources.Get "js/lib/jquery-countdown/jquery.countdown.min.js" -}}
{{- $countdown = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
<!-- APlayer https://github.com/MoePlayer/APlayer -->
{{- /* APlayer https://github.com/MoePlayer/APlayer */ -}}
{{- $aplayer_css := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.aplayer_css -}}
{{- $aplayer_css = .Site.Params.cdn.aplayer_css -}}
{{- else -}}
{{- $res := resources.Get "css/lib/aplayer/APlayer.min.css" | resources.Minify -}}
{{- $res := resources.Get "css/lib/aplayer/APlayer.min.css" -}}
{{- $aplayer_css = printf "<link rel=\"stylesheet\" href=\"%s\">" $res.RelPermalink -}}
{{- end -}}
{{- $aplayer_js := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.aplayer_js -}}
{{- $aplayer_js = .Site.Params.cdn.aplayer_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/aplayer/APlayer.min.js" | resources.Minify -}}
{{- $res := resources.Get "js/lib/aplayer/APlayer.min.js" -}}
{{- $aplayer_js = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
{{- $aplayer := delimit (slice $aplayer_css $aplayer_js) "" -}}
<!-- MetingJS https://github.com/metowolf/MetingJS -->
{{- /* MetingJS https://github.com/metowolf/MetingJS */ -}}
{{- $meting := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.meting_js -}}
{{- $meting = .Site.Params.cdn.meting_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/meting/Meting.min.js" | resources.Minify -}}
{{- $res := resources.Get "js/lib/meting/Meting.min.js" -}}
{{- $meting = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
{{- /* ECharts https://github.com/apache/incubator-echarts */ -}}
{{- $echarts_js := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.echarts_js -}}
{{- $echarts_js = .Site.Params.cdn.echarts_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/echarts/echarts.min.js" -}}
{{- $echarts_js = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
{{- $echarts_macarons_js := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.echarts_macarons_js -}}
{{- $echarts_macarons_js = .Site.Params.cdn.echarts_macarons_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/echarts/macarons.js" | minify -}}
{{- $echarts_macarons_js = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
{{- $echarts := delimit (slice $echarts_js $echarts_macarons_js) "" -}}
{{- $jquery | safeHTML -}}
{{- $lazysizes | safeHTML -}}
{{- $smooth_scroll | safeHTML -}}
{{- if .IsPage -}}
{{/* dev feature */}}
{{- if .Params.dev -}}
{{- with .Scratch.Get "echartsMap" -}}
{{- $echarts | safeHTML -}}
<script>
window.echartsMap = {
{{- range $key, $var := . -}}
{{- $key }}: {{ $var | safeJS -}},
{{- end -}}
};
window.echartsArr=[];
</script>
{{- end -}}
{{- end -}}
{{/* dev feature */}}
{{- with .Scratch.Get "mermaidMap" -}}
{{- $mermaid | safeHTML -}}
<script>
window.mermaidMap = {{ . | jsonify | safeJS }};
{{- printf "window.mermaidMap=%s;" (jsonify .) | safeJS -}}
</script>
{{- end -}}
@ -153,26 +146,40 @@
{{- with .Scratch.Get "countdownMap" -}}
{{- $countdown | safeHTML -}}
<script>
window.countdownMap = {{ . | jsonify | safeJS }};
{{- printf "window.countdownMap=%s;" (jsonify .) | safeJS -}}
</script>
{{- end -}}
{{- /* dev feature */ -}}
{{- if .Params.dev -}}
{{- with .Scratch.Get "echartsMap" -}}
{{- $echarts | safeHTML -}}
<script>
window.echartsMap = {
{ { - range $key, $var := .-} }
{ { - $key } }: { { $var | safeJS -} },
{ { - end -} }
};
window.echartsArr = [];
</script>
{{- end -}}
{{- end -}}
{{- end -}}
{{- $typeitMap := .Scratch.Get "typeitMap" -}}
{{- if $typeitMap -}}
{{- with .Scratch.Get "typeitMap" -}}
{{- $typeit | safeHTML -}}
{{- $typeitArr := slice -}}
{{- range $key, $val := $typeitMap -}}
{{- range $key, $val := . -}}
{{- $typeitArr = $typeitArr | append (slice $val) -}}
{{- end -}}
<script>
window.typeitArr = {{ $typeitArr | jsonify | safeJS }};
{{- printf "window.typeitArr=%s;" (jsonify $typeitArr) | safeJS -}}
</script>
{{- end -}}
{{- $res := resources.Get "/js/blog.js" | resources.Minify -}}
{{- $res := resources.Get "/js/blog.js" | minify -}}
<script src="{{ $res.RelPermalink }}"></script>
{{- if not .Site.IsServer -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.GoogleAnalytics -}}
{{- template "_internal/google_analytics_async.html" . -}}
{{- end -}}

View file

@ -1,3 +1,4 @@
{{- /* Home SEO */ -}}
{{- if .IsHome -}}
<script type="application/ld+json">
{
@ -25,7 +26,9 @@
"name": "{{ .Site.Title }}"
}
</script>
{{ else if .IsPage -}}
{{- /* Page SEO */ -}}
{{- else if .IsPage -}}
<script type="application/ld+json">
{
"@context": "http://schema.org",

View file

@ -1,31 +1,32 @@
{{- define "title" }}{{ .Title }} | {{ .Site.Title }}{{ end -}}
{{- define "content" -}}
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
{{- $author := .Params.author | default .Site.Author.name -}}
{{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}}
<article class="page">
{{- /* Title */ -}}
<h1 class="post-title animated flipInX">{{ .Title }}</h1>
{{- /* Meta */ -}}
<div class="post-meta">
<div class="post-meta-main">
{{- $author := .Params.author | default .Site.Author.name -}}
{{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}}
<a class="author" href="{{ $author_link }}" rel="author" target="_blank">
<i class="fas fa-user-circle fa-fw"></i>{{ $author }}&nbsp;
</a>
<i class="fas fa-user-circle fa-fw"></i>{{ $author }}
</a>&nbsp;
{{- with .Params.categories -}}
<span class="post-category">
{{- T "included" -}}&nbsp;
{{- range . -}}
{{- $name := . -}}
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}}
<i class="far fa-folder fa-fw"></i><a href="{{ .Permalink }}">{{ $name | humanize }}</a>
<i class="far fa-folder fa-fw"></i><a href="{{ .Permalink }}">{{ $name | humanize }}</a>&nbsp;
{{- end -}}
{{- end -}}
</span>
{{- end -}}
</div>
<div class="post-meta-other">
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
<i class="far fa-calendar-alt fa-fw"></i><time datetime={{ $publish_date }}>{{ $publish_date }}</time>&nbsp;
<i class="fas fa-pencil-alt fa-fw"></i>{{ T "wordCount" .WordCount }}&nbsp;
<i class="far fa-clock fa-fw"></i>{{ T "readingTime" .ReadingTime }}&nbsp;
@ -37,12 +38,14 @@
</div>
</div>
{{- /* Featured image */ -}}
{{- with .Params.featured_image -}}
<div class="post-featured-image">
{{- partial "image" . -}}
</div>
{{- end -}}
{{- /* TOC */ -}}
{{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
<div class="post-toc" id="post-toc">
<h2 class="post-toc-title">{{ T "toc" }}</h2>
@ -68,12 +71,15 @@
</div>
{{- end -}}
{{- /* Content */ -}}
<div class="post-content">
{{- partial "hook/content.html" .Content | safeHTML -}}
</div>
{{- /* Footer */ -}}
{{- partial "post/footer.html" . -}}
{{- /* Comment */ -}}
<div class="post-comment">
{{- if ( .Params.comment | default true ) -}}
{{- partial "comments.html" . -}}

View file

@ -4,6 +4,7 @@
{{- define "content" -}}
<div class="page archive">
{{- /* Title */ -}}
<h2 class="post-title animated pulse faster">
{{- $taxonomy := .Data.Singular -}}
{{- if eq $taxonomy "category" -}}
@ -15,6 +16,7 @@
{{- end -}}
</h2>
{{- /* Paginate */ -}}
{{- range (.Paginate (.Pages.GroupByDate "2006")).PageGroups -}}
<h3>{{ .Key }}</h3>
{{- range .Pages -}}

View file

@ -8,11 +8,12 @@
{{- $type := .Type -}}
<div class="page archive">
{{- /* Title */ -}}
<h2 class="post-title animated pulse faster">
{{- T "all" | humanize}}{{ T $taxonomies | default $taxonomies | humanize -}}
</h2>
<!-- Categories Page -->
{{- /* Categories Page */ -}}
{{- if eq $taxonomies "categories" -}}
<div class="categories-card">
{{- range $terms -}}
@ -44,14 +45,13 @@
{{- end -}}
</div>
<!-- Tag Cloud Page -->
{{- /* Tag Cloud Page */ -}}
{{- else if eq $taxonomies "tags" -}}
<div class="tag-cloud-tags">
{{- range $.Site.Taxonomies.tags.ByCount -}}
<a href="{{ .Page.Permalink }}"> {{ .Page.Title }} <small>({{ .Count }})</small></a>
{{- end -}}
</div>
{{- end -}}
</div>
{{- end -}}