diff options
Diffstat (limited to 'layouts')
31 files changed, 1075 insertions, 0 deletions
diff --git a/layouts/404.html b/layouts/404.html new file mode 100644 index 0000000..171fe09 --- /dev/null +++ b/layouts/404.html @@ -0,0 +1,18 @@ +{{- define "title" }}404 page not found - {{ .Site.Title }}{{ end -}} + +{{- define "content" -}} +<div class="not-found"> + <h1 class="error-emoji"></h1> + <p class="error-text">/* 404 page not found. */</p> + <p class="error-link"><a href="{{ "/" | relLangURL }}">↑ Back Home ↑</a></p> +</div> +<script> + var errorEmojiContainer = document.getElementsByClassName('error-emoji')[0]; + var emojiArray = [ + '\\(o_o)/', '(o^^)o', '(˚Δ˚)b', '(^-^*)', '(≥o≤)', '(^_^)b', '(·_·)', + '(=\'X\'=)', '(>_<)', '(;-;)', '\\(^Д^)/', + ]; + var errorEmoji = emojiArray[Math.floor(Math.random() * emojiArray.length)]; + errorEmojiContainer.appendChild(document.createTextNode(errorEmoji)); +</script> +{{- end -}} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html new file mode 100644 index 0000000..1dc8cdc --- /dev/null +++ b/layouts/_default/baseof.html @@ -0,0 +1,46 @@ +{{ if ne .Site.Params.version "4.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/olOwOlo/hugo-theme-even#installation \n 2. You have an incompatible update. See https://github.com/olOwOlo/hugo-theme-even/blob/master/CHANGELOG.md#400-2018-11-06 \n\n有两种可能的情况会导致这个错误发生:\n 1. 你还没有复制 config.toml 参考 https://github.com/olOwOlo/hugo-theme-even/blob/master/README-zh.md#installation \n 2. 你进行了一次不兼容的更新 参考 https://github.com/olOwOlo/hugo-theme-even/blob/master/CHANGELOG.md#400-2018-11-06 \n" -}} +{{ end -}} +<!DOCTYPE html> +<html lang="{{ .Site.Language }}"> +<head> + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> + <title> + {{- block "title" . -}} + {{ if .IsPage }}{{ .Title }} - {{ .Site.Title }}{{ else }}{{ .Site.Title }}{{ end }} + {{- end -}} + </title> + {{ partial "head.html" . }} +</head> +<body> + {{ partial "slideout.html" . }} + <div class="container" id="mobile-panel"> + {{ if not .Params.hideHeaderAndFooter -}} + <header id="header" class="header"> + {{ partial "header.html" . }} + </header> + {{- end }} + + <main id="main" class="main"> + <div class="content-wrapper"> + <div id="content" class="content"> + {{ block "content" . }}{{ end }} + </div> + {{ partial "comments.html" . }} + </div> + </main> + + {{ if not .Params.hideHeaderAndFooter -}} + <footer id="footer" class="footer"> + {{ partial "footer.html" . }} + </footer> + {{- end }} + + <div class="back-to-top" id="back-to-top"> + <i class="iconfont icon-up"></i> + </div> + </div> + {{ partial "scripts.html" . }} +</body> +</html> diff --git a/layouts/_default/section.html b/layouts/_default/section.html new file mode 100644 index 0000000..b61e67e --- /dev/null +++ b/layouts/_default/section.html @@ -0,0 +1,50 @@ +{{- define "title" }}{{ T "archive" }} - {{ .Site.Title }}{{ end -}} + +{{- define "content" }} +{{- $paginator := .Paginate .Data.Pages.ByDate.Reverse .Site.Params.archivePaginate }} +<section id="archive" class="archive"> + {{- if and (not $paginator.HasPrev) .Site.Params.showArchiveCount }} + <div class="archive-title"> + <span class="archive-post-counter"> + {{ T "archiveCounter" (len .Data.Pages) }} + </span> + </div> + {{- end -}} + + {{- range $index, $element := $paginator.Pages -}} + {{- $thisYear := $element.Date.Format "2006" }} + {{- $lastElement := $index | add -1 | index $paginator.Pages }} + {{- if or (eq $index 0) ( ne ($lastElement.Date.Format "2006") $thisYear ) }} + <div class="collection-title"> + <h2 class="archive-year">{{ $thisYear }}</h2> + </div> + {{- end }} + + <div class="archive-post"> + <span class="archive-post-time"> + {{ $element.Date.Format "01-02" }} + </span> + <span class="archive-post-title"> + <a href="{{ $element.RelPermalink }}" class="archive-post-link"> + {{ .Title }} + </a> + </span> + </div> + {{- end -}} +</section> +<!-- pagination --> +<nav class="pagination"> + {{ with $paginator.Prev -}} + <a class="prev" href="{{ .URL }}"> + <i class="iconfont icon-left"></i> + <span class="prev-text">{{ T "prevPage" }}</span> + </a> + {{- end }} + {{ with $paginator.Next -}} + <a class="next" href="{{ .URL }}"> + <span class="next-text">{{ T "nextPage" }}</span> + <i class="iconfont icon-right"></i> + </a> + {{- end }} +</nav> +{{- end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html new file mode 100644 index 0000000..96fe3bf --- /dev/null +++ b/layouts/_default/single.html @@ -0,0 +1,7 @@ +{{ define "content" -}} +<article class="post"> + <div class="post-content"> + {{ .Content }} + </div> +</article> +{{- end }}
\ No newline at end of file diff --git a/layouts/_default/single.md b/layouts/_default/single.md new file mode 100644 index 0000000..57705e2 --- /dev/null +++ b/layouts/_default/single.md @@ -0,0 +1 @@ +{{ .RawContent }}
\ No newline at end of file diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html new file mode 100644 index 0000000..346c2bf --- /dev/null +++ b/layouts/_default/taxonomy.html @@ -0,0 +1,46 @@ +{{- define "title" }}{{ .Title }} · {{ .Site.Title }}{{ end -}} + +{{- define "content" }} +{{- $paginator := .Paginate .Data.Pages .Site.Params.archivePaginate -}} +<section id="archive" class="archive"> + {{ if not $paginator.HasPrev -}} + {{ if eq .Data.Plural "tags" -}} + <div class="archive-title tag"> + <h2 class="archive-name">{{ .Title }}</h2> + </div> + {{- else if eq .Data.Plural "categories" -}} + <div class="archive-title category"> + <h2 class="archive-name">{{ .Title }}</h2> + </div> + {{- end }} + {{- end }} + + {{ range $paginator.Pages -}} + <div class="archive-post"> + <span class="archive-post-time"> + {{ .Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} + </span> + <span class="archive-post-title"> + <a href="{{ .RelPermalink }}" class="archive-post-link"> + {{ .Title }} + </a> + </span> + </div> + {{- end }} +</section> +<!-- pagination --> +<nav class="pagination"> + {{ with $paginator.Prev -}} + <a class="prev" href="{{ .URL }}"> + <i class="iconfont icon-left"></i> + <span class="prev-text">{{ T "prevPage" }}</span> + </a> + {{- end }} + {{ with $paginator.Next -}} + <a class="next" href="{{ .URL }}"> + <span class="next-text">{{ T "nextPage" }}</span> + <i class="iconfont icon-right"></i> + </a> + {{- end }} +</nav> +{{- end }} diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html new file mode 100644 index 0000000..e76cde8 --- /dev/null +++ b/layouts/_default/terms.html @@ -0,0 +1,44 @@ +{{- define "title" }}{{ T .Data.Plural }} - {{ .Site.Title }}{{ end -}} + +{{- define "content" -}} + {{ $name := .Data.Plural -}} + {{ $terms := .Data.Terms.ByCount -}} + {{ $length := len $terms -}} + {{ if eq $name "categories" -}} + <div class="terms"> + <div class="terms-title"> + {{ if eq $length 0 -}} + {{ T "zeroCategoryCounter" }} + {{- else -}} + {{ T "categoryCounter" $length }} + {{- end }} + </div> + <div class="terms-tags"> + {{ range $key, $value := $terms -}} + <a class="terms-link" href="{{ $name | relLangURL }}/{{ $value.Term | urlize }}{{ if $.Site.Params.uglyURLs }}.html{{else}}/{{ end }}"> + {{ $value.Term }} + <span class="terms-count">{{ len $value.Pages }}</span> + </a> + {{ end -}} + </div> + </div> + {{- else if eq $name "tags" -}} + <div class="terms"> + <div class="terms-title"> + {{ if eq $length 0 -}} + {{ T "zeroTagCounter" }} + {{- else -}} + {{ T "tagCounter" $length }} + {{- end }} + </div> + <div class="terms-tags"> + {{- range $key, $value := $terms }} + <a class="terms-link" href="{{ $name | relLangURL }}/{{ $value.Term | urlize }}{{ if $.Site.Params.uglyURLs }}.html{{else}}/{{ end }}"> + {{ $value.Term }} + <span class="terms-count">{{ len $value.Pages }}</span> + </a> + {{ end -}} + </div> + </div> + {{- end }} +{{- end }} diff --git a/layouts/index.html b/layouts/index.html new file mode 100644 index 0000000..3970758 --- /dev/null +++ b/layouts/index.html @@ -0,0 +1,24 @@ +{{- define "content" -}} + <section id="posts" class="posts"> + {{/* (index .Site.Paginate) */}} + {{- $paginator := .Paginate (where (where .Site.RegularPages "Type" "post") ".Params.hiddenfromhomepage" "!=" true) }} + {{- range $paginator.Pages -}} + {{ .Render "summary" }} + {{ end -}} + </section> + <!-- pagination --> + <nav class="pagination"> + {{ with $paginator.Prev -}} + <a class="prev" href="{{ .URL }}"> + <i class="iconfont icon-left"></i> + <span class="prev-text">{{ T "prevPage" }}</span> + </a> + {{- end }} + {{ with $paginator.Next -}} + <a class="next" href="{{ .URL }}"> + <span class="next-text">{{ T "nextPage" }}</span> + <i class="iconfont icon-right"></i> + </a> + {{- end }} + </nav> +{{- end -}} diff --git a/layouts/partials/comments.html b/layouts/partials/comments.html new file mode 100644 index 0000000..7fd6676 --- /dev/null +++ b/layouts/partials/comments.html @@ -0,0 +1,138 @@ +{{ if and .IsPage (ne .Params.comment false) -}} + <!-- Disqus --> + {{- if .Site.DisqusShortname -}} + <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... + if (window.location.hostname === 'localhost') return; + + var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; + var disqus_shortname = '{{ .Site.DisqusShortname }}'; + dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; + (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); + })(); + </script> + <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> + {{- end -}} + + <!-- changyan --> + {{- if and .Site.Params.changyanAppid .Site.Params.changyanAppkey -}} + <div id="SOHUCS" sid="{{ .RelPermalink }}"></div> + <script type="text/javascript"> + (function(){ + if (window.location.hostname === 'localhost') return; + + var appid = '{{ .Site.Params.changyanAppid }}'; + var conf = '{{ .Site.Params.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> + {{- end -}} + + <!-- LiveRe --> + {{- if .Site.Params.livereUID -}} + <div id="lv-container" data-id="city" data-uid="{{ .Site.Params.livereUID }}"> + <script type="text/javascript"> + (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> + {{- end -}} + + <!-- gitment --> + {{- if .Site.Params.gitment.owner -}} + <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> + {{- end -}} + + <!-- gitalk --> + {{- if .Site.Params.gitalk.owner -}} + <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 type="text/javascript"> + 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> + {{- end }} + + <!-- valine --> + {{- if .Site.Params.valine.enable -}} + <!-- id 将作为查询条件 --> + {{- if .Site.Params.valine.visitor -}} + <span id="{{ .RelPermalink | relURL }}" 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 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 }} + + <!-- utterances --> + {{- if .Site.Params.utterances.owner}} + <script src="https://utteranc.es/client.js" + repo="{{ .Site.Params.utterances.owner }}/{{ .Site.Params.utterances.repo }}" + issue-term="pathname" + theme="github-light" + crossorigin="anonymous" + async> + </script> + <noscript>Please enable JavaScript to view the <a href="https://github.com/utterance">comments powered by utterances.</a></noscript> + {{- end }} + +{{- end }} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html new file mode 100644 index 0000000..9dea06d --- /dev/null +++ b/layouts/partials/footer.html @@ -0,0 +1,53 @@ +<div class="social-links"> + {{- range $name, $path := .Site.Params.social }} + {{- if $path }} + {{- $realName := slicestr $name 2 }} + <a href="{{ $path | safeURL }}" class="iconfont icon-{{ $realName }}" title="{{ $realName }}"></a> + {{- end }} + {{- end }} + {{ if .Site.LanguagePrefix -}} + <a href="{{ .Site.LanguagePrefix | absURL }}/index.xml" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a> + {{- else -}} + <a href="https://banyan.divineduty.xyz" class="icons pleroma" title="Pleroma"></a> + <a href="{{ .Site.RSSLink }}" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a> + {{- end }} +</div> + +<div class="copyright"> + <span class="power-by"> + {{ (printf (T "powered") `<a class="hexo-link" href="https://gohugo.io">Hugo</a>`) | safeHTML }} + </span> + <span class="division">|</span> + <span class="theme-info"> + {{ T "theme" }} - + <a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a> + <br> + <a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons Licence" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a> + </span> + + {{ if .Site.Params.busuanzi.enable -}} + <div class="busuanzi-footer"> + {{ $spinner := "img/spinner.svg" | relURL -}} + {{ if and .Site.Params.busuanzi.enable .Site.Params.busuanzi.sitePV -}} + {{ $valueSpan := printf `<span id="busuanzi_value_site_pv"><img src="%s" alt="spinner.svg"/></span>` $spinner -}} + <span id="busuanzi_container_site_pv"> {{ printf (T "sitePV") $valueSpan | safeHTML }} </span> + {{ if .Site.Params.busuanzi.siteUV }}<span class="division">|</span>{{ end }} + {{- end }} + {{ if and .Site.Params.busuanzi.enable .Site.Params.busuanzi.siteUV -}} + {{ $valueSpan := printf `<span id="busuanzi_value_site_uv"><img src="%s" alt="spinner.svg"/></span>` $spinner -}} + <span id="busuanzi_container_site_uv"> {{ printf (T "siteUV") $valueSpan | safeHTML }} </span> + {{- end }} + </div> + {{- end }} + + <span class="copyright-year"> + {{- $current := now.Format "2006" }} + © + {{ if ne .Site.Params.since $current -}} + {{ .Site.Params.since }} - + {{ end }} + {{- $current -}} + <span class="heart"><i class="iconfont icon-heart"></i></span><!-- + --><span>{{if .Site.Copyright }}{{ .Site.Copyright | safeHTML }}{{ else }}{{ .Site.Author.name | safeHTML }}{{ end }}</span> + </span> +</div> diff --git a/layouts/partials/head.html b/layouts/partials/head.html new file mode 100644 index 0000000..483339d --- /dev/null +++ b/layouts/partials/head.html @@ -0,0 +1,91 @@ +<meta name="renderer" content="webkit" /> +<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/> + +<meta http-equiv="Cache-Control" content="no-transform" /> +<meta http-equiv="Cache-Control" content="no-siteapp" /> + +<meta name="theme-color" content="#f8f5ec" /> +<meta name="msapplication-navbutton-color" content="#f8f5ec"> +<meta name="apple-mobile-web-app-capable" content="yes"> +<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec"> + +<!-- author & description & keywords --> +<meta name="author" content="{{ if .Params.author }}{{ .Params.author | safeHTML }}{{ else }}{{ .Site.Author.name | safeHTML }}{{ end }}" /> + +{{- if .Description -}} + <meta name="description" content="{{ .Description | safeHTML }}" /> +{{- else if .IsPage -}} + <meta name="description" content="{{ .Summary | plainify }}" /> +{{- else if .Site.Params.description -}} + <meta name="description" content="{{ .Site.Params.description | safeHTML }}" /> +{{- end -}} + +{{- if .Keywords -}} + {{ $length := len .Keywords | add -1 -}} + <meta name="keywords" content="{{ range $index, $element := .Keywords }}{{ $element | safeHTML }}{{if ne $index $length }}, {{ end }}{{ end }}" /> +{{- else if .Site.Params.keywords -}} + {{ $length := len .Site.Params.keywords | add -1 -}} + <meta name="keywords" content="{{ range $index, $element := .Site.Params.keywords }}{{ $element | safeHTML }}{{if ne $index $length }}, {{ end }}{{ end }}" /> +{{- end }} + +<!-- baidu & google verification --> +{{ with .Site.Params.baiduVerification }}<meta name="baidu-site-verification" content="{{.}}" />{{ end }} +{{ with .Site.Params.googleVerification }}<meta name="google-site-verification" content="{{.}}" />{{ end }} + +<!-- Site Generator --> +<meta name="generator" content="Hugo {{ .Site.Hugo.Version }} with theme even" /> + +<!-- Permalink & RSSlink --> +<link rel="canonical" href="{{ .Permalink }}" /> +{{- with .OutputFormats.Get "RSS" }} + <link href="{{ .Permalink }}" rel="alternate" type="application/rss+xml" title="{{ $.Site.Title }}" /> + <link href="{{ .Permalink }}" rel="feed" type="application/rss+xml" title="{{ $.Site.Title }}" /> +{{- end -}} + +<!-- Favicon and Touch icons --> +<link rel="apple-touch-icon" sizes="180x180" href="{{ "apple-touch-icon.png" | relURL }}"> +<link rel="icon" type="image/png" sizes="32x32" href="{{ "favicon-32x32.png" | relURL }}"> +<link rel="icon" type="image/png" sizes="16x16" href="{{ "favicon-16x16.png" | relURL }}"> +<link rel="manifest" href="{{ "manifest.json" | relURL }}"> +<link rel="mask-icon" href="{{ "safari-pinned-tab.svg" | relURL }}" color="#5bbad5"> + +<!-- debug --> +{{- if .Site.Params.debug -}} +<script src="https://cdn.jsdelivr.net/npm/eruda@1.2.6/eruda.min.js" integrity="sha256-Jmz4bc3kp+rRrXX2tGadNBKFLwtzMapr8kHABxSAAP8=" crossorigin="anonymous"></script> +<script>eruda.init();</script> +{{- end -}} + +<!-- busuanzi --> +{{- if .Site.Params.busuanzi.enable -}} + <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script> +{{- end -}} + +<!-- Styles --> +{{ $style := resources.Get "sass/main.scss" | toCSS | minify | fingerprint }} +<link href="{{ $style.RelPermalink }}" rel="stylesheet"> +{{ if .Site.Params.publicCDN.enable -}} + {{ if .Site.Params.fancybox }}{{ .Site.Params.publicCDN.fancyboxCSS | safeHTML }}{{ end }} +{{- else -}} + {{ if .Site.Params.fancybox }}<link href="{{ "lib/fancybox/jquery.fancybox-3.1.20.min.css" | relURL }}" rel="stylesheet">{{ end }} +{{- end -}} + +<!-- custom css --> +{{ range .Site.Params.customCSS -}} +<link rel="stylesheet" href="{{ "/css/" | relURL }}{{ . }}"> +{{ end }} + +{{/* NOTE: These Hugo Internal Templates can be found starting at https://github.com/spf13/hugo/blob/master/tpl/tplimpl/template_embedded.go#L158 */}} +{{- template "_internal/opengraph.html" . -}} +{{- template "_internal/google_news.html" . -}} +{{- template "_internal/schema.html" . -}} +{{- template "_internal/twitter_cards.html" . -}} + +<!-- Polyfill for old browsers --> +{{ `<!--[if lte IE 9]> + <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script> +<![endif]-->` | safeHTML }} + +{{ `<!--[if lt IE 9]> + <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script> + <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script> +<![endif]-->` | safeHTML }} diff --git a/layouts/partials/header.html b/layouts/partials/header.html new file mode 100644 index 0000000..24d5b37 --- /dev/null +++ b/layouts/partials/header.html @@ -0,0 +1,21 @@ +<div class="logo-wrapper"> + <a href="{{ "/" | relLangURL }}" class="logo"> + {{- if .Site.Params.logoTitle -}} + {{ .Site.Params.logoTitle }} + {{- else -}} + {{ .Site.Title }} + {{- end -}} + </a> +</div> + +{{ partial "header/language-selector.html" . }} + +<nav class="site-navbar"> + <ul id="menu" class="menu"> + {{ range .Site.Menus.main -}} + <li class="menu-item"> + <a class="menu-item-link" href="{{ .URL | safeURL }}">{{ .Name }}</a> + </li> + {{- end }} + </ul> +</nav> diff --git a/layouts/partials/header/language-selector.html b/layouts/partials/header/language-selector.html new file mode 100644 index 0000000..e28650e --- /dev/null +++ b/layouts/partials/header/language-selector.html @@ -0,0 +1,25 @@ +<!-- + Language selector. + + If current page has version in another language, language link will lead + to the translated page. If not, the link will be to the home page of the site + with specified language. +--> +{{ if (and (.Site.IsMultiLingual) ($.Site.Params.showLanguageSelector)) }} + <div class="language-selector"> + <ul class="languages-list"> + {{ range $homeTranslation := .Site.Home.AllTranslations }} + {{ $active := eq $homeTranslation.Language $.Site.Language }} + {{ $pageTranslation := (index (where $.Page.AllTranslations "Language.Lang" "eq" $homeTranslation.Language.Lang) 0) }} + + <li class="language-item {{if $active}}active{{end}}"> + {{ with $pageTranslation }} + <a href="{{ .Permalink }}">{{ .Language.Lang }}</a> + {{ else }} + <a href="{{ $homeTranslation.Permalink }}">{{ .Language.Lang }}</a> + {{ end }} + </li> + {{ end }} + </ul> + </div> +{{ end }} diff --git a/layouts/partials/icons.html b/layouts/partials/icons.html new file mode 100644 index 0000000..9c1f5df --- /dev/null +++ b/layouts/partials/icons.html @@ -0,0 +1,6 @@ +<span class="inline-svg" > + {{- $fname:=print "icons/" . ".svg" -}} + {{- $path:="<path" -}} + {{- $fill:="<path fill=\"currentColor\"" -}} + {{ replace (readFile $fname) $path $fill | safeHTML }} +</span>
\ No newline at end of file diff --git a/layouts/partials/post/copyright.html b/layouts/partials/post/copyright.html new file mode 100644 index 0000000..35a7609 --- /dev/null +++ b/layouts/partials/post/copyright.html @@ -0,0 +1,35 @@ +{{ if or .Params.postMetaInFooter (and .Site.Params.postMetaInFooter (ne .Params.postMetaInFooter false)) -}} +<div class="post-copyright"> + <p class="copyright-item"> + <span class="item-title">{{ T "author" }}</span> + <span class="item-content">{{ if .Params.author }}{{ .Params.author | safeHTML }}{{ else }}{{ .Site.Author.name | safeHTML }}{{ end }}</span> + </p> + <p class="copyright-item"> + <span class="item-title">{{ T "lastMod" }}</span> + <span class="item-content"> + {{ .Lastmod.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} + {{ with .GitInfo }}<a href="{{ $.Site.Params.gitRepo }}/commit/{{ .Hash }}" title="{{ .Subject }}">({{ .AbbreviatedHash }})</a>{{ end }} + </span> + </p> + {{ if $.Site.Params.linkToMarkDown -}} + {{ with $.OutputFormats.Get "markdown" -}} + <p class="copyright-item"> + <span class="item-title">{{ T "markdown" }}</span> + <span class="item-content"><a class="link-to-markdown" href="{{ .Permalink }}" target="_blank">{{ T "seeMarkDown" }}</a></span> + </p> + {{- end }} + {{- end }} + {{ if or .Params.contentCopyright (and .Site.Params.contentCopyright (ne .Params.contentCopyright false)) -}} + <p class="copyright-item"> + <span class="item-title">{{ T "license" }}</span> + <span class="item-content"> + {{- if .Params.contentCopyright -}} + {{ .Params.contentCopyright | safeHTML }} + {{- else -}} + {{ .Site.Params.contentCopyright | safeHTML }} + {{- end -}} + </span> + </p> + {{- end }} +</div> +{{- end }} diff --git a/layouts/partials/post/outdated-info-warning.html b/layouts/partials/post/outdated-info-warning.html new file mode 100644 index 0000000..3736c13 --- /dev/null +++ b/layouts/partials/post/outdated-info-warning.html @@ -0,0 +1,28 @@ +{{- if or .Params.enableOutdatedInfoWarning (and .Site.Params.outdatedInfoWarning.enable (ne .Params.enableOutdatedInfoWarning false)) }} + {{- $daysAgo := div (sub now.Unix .Lastmod.Unix) 86400 }} + {{- $hintThreshold := .Site.Params.outdatedInfoWarning.hint | default 30 }} + {{- $warnThreshold := .Site.Params.outdatedInfoWarning.warn | default 180 }} + + {{- $updateTime := .Lastmod }} + {{- if .GitInfo }} + {{- if lt .GitInfo.AuthorDate.Unix .Lastmod.Unix }} + {{- $updateTime := .GitInfo.AuthorDate }} + {{- end }} + {{- end -}} + + {{- if gt $daysAgo $hintThreshold }} + <div class="post-outdated"> + {{- if gt $daysAgo $warnThreshold }} + <div class="warn"> + {{- else }} + <div class="hint"> + {{- end }} + <p>{{ T "outdatedInfoWarningBefore" -}} + <span class="timeago" datetime="{{ dateFormat "2006-01-02T15:04:05" $updateTime }}" title="{{ dateFormat "January 2, 2006" $updateTime }}"> + {{- dateFormat "January 2, 2006" $updateTime -}} + </span>{{ T "outdatedInfoWarningAfter" -}} + </p> + </div> + </div> + {{- end -}} +{{- end -}} diff --git a/layouts/partials/post/reward.html b/layouts/partials/post/reward.html new file mode 100644 index 0000000..baceac7 --- /dev/null +++ b/layouts/partials/post/reward.html @@ -0,0 +1,21 @@ +{{ if or .Params.reward (and .Site.Params.reward.enable (ne .Params.reward false)) -}} +<div class="post-reward"> + <input type="checkbox" name="reward" id="reward" hidden /> + <label class="reward-button" for="reward">{{ T "reward" }}</label> + <div class="qr-code"> + {{ $qrCode := .Site.Params.reward }} + {{ with $qrCode.wechat -}} + <label class="qr-code-image" for="reward"> + <img class="image" src="{{ . }}"> + <span>{{ T "rewardWechat" }}</span> + </label> + {{- end }} + {{ with $qrCode.alipay -}} + <label class="qr-code-image" for="reward"> + <img class="image" src="{{ . }}"> + <span>{{ T "rewardAlipay" }}</span> + </label> + {{- end }} + </div> +</div> +{{- end }}
\ No newline at end of file diff --git a/layouts/partials/post/toc.html b/layouts/partials/post/toc.html new file mode 100644 index 0000000..759ad43 --- /dev/null +++ b/layouts/partials/post/toc.html @@ -0,0 +1,9 @@ +{{ 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> + {{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default false }} + <div class="post-toc-content{{ if not (or .Params.autoCollapseToc (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false))) }} always-active{{ end }}"> + {{.TableOfContents}} + </div> +</div> +{{- end }}
\ No newline at end of file diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html new file mode 100644 index 0000000..71fe659 --- /dev/null +++ b/layouts/partials/scripts.html @@ -0,0 +1,135 @@ +<!-- highlight.js --> +{{- if .Site.Params.highlightInClient -}} + <script src="{{ "lib/highlight/highlight.pack.js?v=20171001" | relURL }}"></script> +{{- end -}} + +<!-- core --> +{{- if .Site.Params.publicCDN.enable }} + {{ .Site.Params.publicCDN.jquery | safeHTML }} + {{ .Site.Params.publicCDN.slideout | safeHTML }} + {{ if .Site.Params.fancybox }}{{ .Site.Params.publicCDN.fancyboxJS | safeHTML }}{{ end }} +{{- else -}} + <script type="text/javascript" src="{{ "lib/jquery/jquery-3.2.1.min.js" | relURL }}"></script> + <script type="text/javascript" src="{{ "lib/slideout/slideout-1.0.1.min.js" | relURL }}"></script> + {{ if .Site.Params.fancybox }}<script type="text/javascript" src="{{ "lib/fancybox/jquery.fancybox-3.1.20.min.js" | relURL }}"></script>{{ end }} +{{- end -}} + +<!-- timeago.JS --> +{{- if and (or .Params.enableOutdatedInfoWarning (and .Site.Params.outdatedInfoWarning.enable (ne .Params.enableOutdatedInfoWarning false))) (or .IsPage .IsHome) }} + {{- if .Site.Params.publicCDN.enable }} + {{ .Site.Params.publicCDN.timeagoJS | safeHTML }} + {{ .Site.Params.publicCDN.timeagoLocalesJS | safeHTML }} + {{- else }} + <script type="text/javascript" src="{{ "lib/timeago/timeago-3.0.2.min.js" | relURL }}"></script> + <script type="text/javascript" src="{{ "lib/timeago/timeago.locales-3.0.2.min.js" | relURL }}"></script> + {{- end }} + <script><!-- NOTE: timeago.js uses the language code format like "zh_CN" (underscore and case sensitive) --> + var languageCode = {{ .Site.LanguageCode }}.replace(/-/g, '_').replace(/_(.*)/, function ($0, $1) {return $0.replace($1, $1.toUpperCase());}); + timeago().render(document.querySelectorAll('.timeago'), languageCode); + timeago.cancel(); // stop update + </script> +{{- end -}} + +<!-- flowchart --> +{{- if and (or .Params.flowchartDiagrams.enable (and .Site.Params.flowchartDiagrams.enable (ne .Params.flowchartDiagrams.enable false))) (or .IsPage .IsHome) -}} + <script> + {{- if .Params.flowchartDiagrams.options -}} + window.flowchartDiagramsOptions = {{ .Params.flowchartDiagrams.options | safeJS }}; + {{- else if .Site.Params.flowchartDiagrams.options -}} + window.flowchartDiagramsOptions = {{ .Site.Params.flowchartDiagrams.options | safeJS }}; + {{- end -}} + </script> + {{- if .Site.Params.publicCDN.enable -}} + {{ .Site.Params.publicCDN.flowchartDiagramsJS | safeHTML }} + {{- else -}} + <script src="{{ "lib/flowchartDiagrams/raphael-2.2.7.min.js" | relURL }}" integrity="sha256-67By+NpOtm9ka1R6xpUefeGOY8kWWHHRAKlvaTJ7ONI=" crossorigin="anonymous"></script> + <script src="{{ "lib/flowchartDiagrams/flowchart-1.8.0.min.js" | relURL }}" integrity="sha256-zNGWjubXoY6rb5MnmpBNefO0RgoVYfle9p0tvOQM+6k=" crossorigin="anonymous"></script> + {{- end -}} +{{- end -}} + +<!-- js-sequence-diagrams --> +{{- if and (or .Params.sequenceDiagrams.enable (and .Site.Params.sequenceDiagrams.enable (ne .Params.sequenceDiagrams.enable false))) (or .IsPage .IsHome) -}} + <script> + {{- if .Params.sequenceDiagrams.options -}} + window.sequenceDiagramsOptions = {{ .Params.sequenceDiagrams.options | safeJS }}; + {{- else if .Site.Params.sequenceDiagrams.options -}} + window.sequenceDiagramsOptions = {{ .Site.Params.sequenceDiagrams.options | safeJS }}; + {{- end -}} + </script> + {{- if .Site.Params.publicCDN.enable -}} + {{ .Site.Params.publicCDN.sequenceDiagramsJS | safeHTML }} + {{ .Site.Params.publicCDN.sequenceDiagramsCSS | safeHTML }} + {{- else -}} + <script src="{{ "lib/js-sequence-diagrams/webfontloader-1.6.28.js" | relURL }}" integrity="sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=" crossorigin="anonymous"></script> + <script src="{{ "lib/js-sequence-diagrams/snap.svg-0.5.1.min.js" | relURL }}" integrity="sha256-oI+elz+sIm+jpn8F/qEspKoKveTc5uKeFHNNVexe6d8=" crossorigin="anonymous"></script> + <script src="{{ "lib/js-sequence-diagrams/underscore-1.8.3.min.js" | relURL }}" integrity="sha256-obZACiHd7gkOk9iIL/pimWMTJ4W/pBsKu+oZnSeBIek=" crossorigin="anonymous"></script> + <script src="{{ "lib/js-sequence-diagrams/sequence-diagram-2.0.1.min.js" | relURL }}" integrity="sha384-8748Vn52gHJYJI0XEuPB2QlPVNUkJlJn9tHqKec6J3q2r9l8fvRxrgn/E5ZHV0sP" crossorigin="anonymous"></script> + <link rel="stylesheet" href="{{ "lib/js-sequence-diagrams/sequence-diagram-2.0.1.min.css" | relURL }}" integrity="sha384-6QbLKJMz5dS3adWSeINZe74uSydBGFbnzaAYmp+tKyq60S7H2p6V7g1TysM5lAaF" crossorigin="anonymous"> + {{- end -}} +{{- end }} +{{ $even := resources.Get "js/even.js" }} +{{ $main := resources.Get "js/main.js" }} +{{ $js := slice $even $main | resources.Concat "js/main.js" | minify | fingerprint }} +<script type="text/javascript" src="{{ $js.RelPermalink }}"></script> + +{{- if and (or .Params.mathjax (and .Site.Params.mathjax (ne .Params.mathjax false))) (or .IsPage .IsHome) }} + <script type="text/javascript"> + window.MathJax = { + tex: { + {{ if or .Params.mathjaxEnableSingleDollar (and .Site.Params.mathjaxEnableSingleDollar (ne .Params.mathjaxEnableSingleDollar false)) -}} + inlineMath: [['$','$'], ['\\(','\\)']], + {{ end -}} + {{ if or .Params.mathjaxEnableAutoNumber (and .Site.Params.mathjaxEnableAutoNumber (ne .Params.mathjaxEnableAutoNumber false)) -}} + tags: 'ams', + {{ end -}} + } + }; + </script> + {{ if .Site.Params.mathjaxUseLocalFiles -}} + <script type="text/javascript" async src="{{ "lib/mathjax/es5/tex-mml-chtml.js" | relURL }}"></script> + {{- else -}} + <script async src="https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-mml-chtml.js" integrity="sha256-HGLuEfFcsUJGhvB8cQ8nr0gai9EucOOaIxFw7qxmd+w=" crossorigin="anonymous"></script> + {{- end }} +{{- end }} + +<!-- Analytics --> +{{- if (in (slice (getenv "HUGO_ENV") hugo.Environment) "production") | and .Site.GoogleAnalytics -}} + {{ template "_internal/google_analytics_async.html" . }} +{{- end -}} + +{{- with .Site.Params.baiduAnalytics -}} +<script id="baidu_analytics"> + var _hmt = _hmt || []; + (function() { + if (window.location.hostname === 'localhost') return; + var hm = document.createElement("script"); hm.async = true; + hm.src = "https://hm.baidu.com/hm.js?{{.}}"; + var s = document.getElementsByTagName("script")[0]; + s.parentNode.insertBefore(hm, s); + })(); +</script> +{{- end }} + +<!-- baidu push --> +{{- if .Site.Params.baiduPush -}} +<script id="baidu_push"> + (function(){ + if (window.location.hostname === 'localhost') return; + var bp = document.createElement('script'); bp.async = true; + var curProtocol = window.location.protocol.split(':')[0]; + if (curProtocol === 'https') { + bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; + } + else { + bp.src = 'http://push.zhanzhang.baidu.com/push.js'; + } + var s = document.getElementsByTagName("script")[0]; + s.parentNode.insertBefore(bp, s); + })(); +</script> +{{- end }} + +<!-- custom js --> +{{ range .Site.Params.customJS -}} + <script src="{{ "/js/" | relURL }}{{ . }}"></script> +{{ end }} diff --git a/layouts/partials/slideout.html b/layouts/partials/slideout.html new file mode 100644 index 0000000..da0885c --- /dev/null +++ b/layouts/partials/slideout.html @@ -0,0 +1,27 @@ +<div id="mobile-navbar" class="mobile-navbar"> + <div class="mobile-header-logo"> + <a href="{{ "/" | relLangURL }}" class="logo"> + {{- if .Site.Params.logoTitle -}} + {{ .Site.Params.logoTitle }} + {{- else -}} + {{ .Site.Title }} + {{- end -}} + </a> + </div> + <div class="mobile-navbar-icon"> + <span></span> + <span></span> + <span></span> + </div> +</div> +<nav id="mobile-menu" class="mobile-menu slideout-menu"> + <ul class="mobile-menu-list"> + {{ range .Site.Menus.main -}} + <a href="{{ .URL | safeURL }}"> + <li class="mobile-menu-item">{{ .Name }}</li> + </a> + {{- end }} + </ul> + + {{ partial "header/language-selector.html" . }} +</nav> diff --git a/layouts/post/single.html b/layouts/post/single.html new file mode 100644 index 0000000..d138eef --- /dev/null +++ b/layouts/post/single.html @@ -0,0 +1,72 @@ +{{ define "content" -}} + <article class="post"> + <!-- post-header --> + <header class="post-header"> + <h1 class="post-title">{{ .Title }}</h1> + + <div class="post-meta"> + <span class="post-time"> {{ .Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} </span> + {{ with .Params.categories -}} + <div class="post-category"> + {{ range . -}} + <a href="{{ "categories" | relLangURL }}/{{ . | urlize }}/"> {{ . }} </a> + {{ end -}} + </div> + {{- end }} + {{- if .Site.Params.moreMeta }} + <span class="more-meta"> {{ T "wordCount" .WordCount }} </span> + <span class="more-meta"> {{ T "readingTime" .ReadingTime }} </span> + {{- end }} + {{ if and .Site.Params.busuanzi.enable .Site.Params.busuanzi.pagePV -}} + {{ $valueSpan := printf `<span id="busuanzi_value_page_pv"><img src="%s" alt="spinner.svg"/></span>` ("img/spinner.svg" | relURL) -}} + <span id="busuanzi_container_page_pv" class="more-meta"> {{ printf (T "pagePV") $valueSpan | safeHTML }} </span> + {{- end }} + </div> + </header> + + <!-- TOC --> + {{- partial "post/toc.html" . -}} + + <!-- Outdated Info Warning --> + {{- partial "post/outdated-info-warning.html" . -}} + + <!-- Content --> + <div class="post-content"> + {{ .Content }} + </div> + + <!-- Copyright --> + {{- partial "post/copyright.html" . -}} + + <!-- Reward --> + {{- partial "post/reward.html" . -}} + + <footer class="post-footer"> + {{ with .Params.tags -}} + <div class="post-tags"> + {{ range . -}} + <a href="{{ "tags" | relLangURL }}/{{ . | urlize }}{{ if $.Site.Params.uglyURLs }}.html{{ else }}/{{ end }}">{{ . }}</a> + {{ end -}} + </div> + {{- end -}} + + <!-- Post Pagination --> + <nav class="post-nav"> + {{ with .NextInSection -}} + <a class="prev" href="{{ .RelPermalink }}"> + <i class="iconfont icon-left"></i> + <span class="prev-text nav-default">{{ .Title }}</span> + <span class="prev-text nav-mobile">{{ T "prevPost" }}</span> + </a> + {{- end }} + {{ with .PrevInSection -}} + <a class="next" href="{{ .RelPermalink }}"> + <span class="next-text nav-default">{{ .Title }}</span> + <span class="next-text nav-mobile">{{ T "nextPost" }}</span> + <i class="iconfont icon-right"></i> + </a> + {{- end }} + </nav> + </footer> + </article> +{{- end }} diff --git a/layouts/post/summary.html b/layouts/post/summary.html new file mode 100644 index 0000000..38c45f4 --- /dev/null +++ b/layouts/post/summary.html @@ -0,0 +1,28 @@ +<article class="post"> + <header class="post-header"> + <h1 class="post-title"><a class="post-link" href="{{ .RelPermalink }}">{{ .Title }}</a></h1> + <div class="post-meta"> + <span class="post-time"> {{ .Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} </span> + {{ with .Params.categories -}} + <div class="post-category"> + {{ range . -}} + <a href="{{ "categories" | relLangURL }}/{{ . | urlize }}/"> {{ . }} </a> + {{ end -}} + </div> + {{- end }} + {{- if .Site.Params.moreMeta }} + <span class="more-meta"> {{ T "wordCount" .WordCount }} </span> + <span class="more-meta"> {{ T "readingTime" .ReadingTime }} </span> + {{- end }} + </div> + </header> + <!-- Content --> + <div class="post-content"> + <div class="post-summary"> + {{ .Summary }} + </div> + <div class="read-more"> + <a href="{{ .RelPermalink }}" class="read-more-link">{{ T "readMore" }}</a> + </div> + </div> +</article> diff --git a/layouts/robots.txt b/layouts/robots.txt new file mode 100644 index 0000000..e89778e --- /dev/null +++ b/layouts/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Sitemap: {{ "sitemap.xml" | absURL }} diff --git a/layouts/shortcodes/admonition.html b/layouts/shortcodes/admonition.html new file mode 100644 index 0000000..fa5aacb --- /dev/null +++ b/layouts/shortcodes/admonition.html @@ -0,0 +1,37 @@ +{{ if .IsNamedParams -}} + + {{ if eq (.Get "details") "true" -}} + +<details class="admonition {{ .Get "type" }}"> + {{- with .Get "title" }}<summary class="admonition-title">{{ . }}</summary>{{ end }} + {{ .Inner }} +</details> + + {{- else -}} + +<div class="admonition {{ .Get "type" }}"> + {{- with .Get "title" }}<p class="admonition-title">{{ . }}</p>{{ end }} + {{ .Inner }} +</div> + + {{- end }} + +{{- else -}} + + {{ if eq (.Get 2) "true" -}} + +<details class="admonition {{ .Get 0 }}"> + {{- with .Get 1 }}<summary class="admonition-title">{{ . }}</summary>{{ end }} + {{ .Inner }} +</details> + + {{- else -}} + +<div class="admonition {{ .Get 0 }}"> + {{- with .Get 1 }}<p class="admonition-title">{{ . }}</p>{{ end }} + {{ .Inner }} +</div> + + {{- end }} + +{{- end }}
\ No newline at end of file diff --git a/layouts/shortcodes/bilibili.html b/layouts/shortcodes/bilibili.html new file mode 100644 index 0000000..005eccb --- /dev/null +++ b/layouts/shortcodes/bilibili.html @@ -0,0 +1,23 @@ + +{{ $videoID := index .Params 0 }} +{{ $pageNum := index .Params 1 | default 1 }} + +{{ if (findRE "^[bB][vV][0-9a-zA-Z]+$" $videoID) }} +<div><iframe id="biliplayer" src="//player.bilibili.com/player.html?bvid={{ $videoID }}&page={{ $pageNum }}" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" loading="lazy" > </iframe></div> +{{ else }} +<div><iframe id="biliplayer" src="//player.bilibili.com/player.html?aid={{ $videoID }}&page={{ $pageNum }}" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" loading="lazy" > </iframe></div> +{{ end }} + +<style> +// Embed BiliBili Video +#bilibili { + width: 100%; + height: 550px; +} +@media only screen and (min-device-width: 320px) and (max-device-width: 480px) { + #bilibili { + width: 100%; + height: 250px; + } +} +</style> diff --git a/layouts/shortcodes/center.html b/layouts/shortcodes/center.html new file mode 100644 index 0000000..e9022d0 --- /dev/null +++ b/layouts/shortcodes/center.html @@ -0,0 +1,3 @@ +<div class='align-center'> + {{ .Inner }} +</div>
\ No newline at end of file diff --git a/layouts/shortcodes/icons.html b/layouts/shortcodes/icons.html new file mode 100644 index 0000000..2279580 --- /dev/null +++ b/layouts/shortcodes/icons.html @@ -0,0 +1,6 @@ +<span class="inline-svg" > + {{- $fname:=print "icons/" ( .Get 0 ) ".svg" -}} + {{- $path:="<path" -}} + {{- $fill:="<path fill=\"currentColor\"" -}} + {{ replace (readFile $fname) $path $fill | safeHTML }} +</span>
\ No newline at end of file diff --git a/layouts/shortcodes/left.html b/layouts/shortcodes/left.html new file mode 100644 index 0000000..c2c5102 --- /dev/null +++ b/layouts/shortcodes/left.html @@ -0,0 +1,3 @@ +<div class='align-left'> + {{ .Inner }} +</div>
\ No newline at end of file diff --git a/layouts/shortcodes/music.html b/layouts/shortcodes/music.html new file mode 100644 index 0000000..22b2268 --- /dev/null +++ b/layouts/shortcodes/music.html @@ -0,0 +1,62 @@ + {{/* + ## Music 163 + + ### Params: + + - `id` + + required param + you can extract from music url + url format "http://music.163.com/#/song?id=3950552" + + - Fiddle `auto` + + optional param + default value 0 + you can overwrite it with 1 + + ### Examples: + + - Simple + + {{% music "3950552" %}} + {{% music "3950552" "1" %}} + + - Named Params + + {{% music id="3950552" %}} + {{% music id="3950552" auto="1" %}} + + */}} + + {{- /* DEFAULTS */ -}} + {{ $auto := "0" }} + + {{- if .IsNamedParams -}} + + <iframe style="max-width: 100%" + class="music163" + frameborder="no" + border="0" + marginwidth="0" + marginheight="0" + width="330" + height="86" + src="//music.163.com/outchain/player?type=2&id={{ .Get "id" }}&auto={{ or (.Get "auto") $auto }}&height=66"> + </iframe> + + {{- else -}} + + <iframe style="max-width: 100%" + class="music163" + frameborder="no" + border="0" + marginwidth="0" + marginheight="0" + width="330" + height="86" + src="//music.163.com/outchain/player?type=2&id={{ .Get 0 }}&auto={{ if isset .Params 1 }}{{ .Get 1 }}{{ else }}{{ $auto }}{{ end }}&height=66"> + </iframe> + + {{- end -}} +
\ No newline at end of file diff --git a/layouts/shortcodes/right.html b/layouts/shortcodes/right.html new file mode 100644 index 0000000..37a9a33 --- /dev/null +++ b/layouts/shortcodes/right.html @@ -0,0 +1,3 @@ +<div class='align-right'> + {{ .Inner }} +</div>
\ No newline at end of file diff --git a/layouts/sitemap.xml b/layouts/sitemap.xml new file mode 100644 index 0000000..19dd68d --- /dev/null +++ b/layouts/sitemap.xml @@ -0,0 +1,11 @@ +{{ "<?" | safeHTML }}xml-stylesheet type="text/xsl" href="{{ "sitemap.xsl" | absURL }}"{{ "?>" | safeHTML }} +<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> + {{ range .Data.Pages }} + <url> + <loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }} + <lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }} + <changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }} + <priority>{{ .Sitemap.Priority }}</priority>{{ end }} + </url> + {{ end }} +</urlset>
\ No newline at end of file |