diff options
Diffstat (limited to 'layouts/partials')
-rw-r--r-- | layouts/partials/comments.html | 138 | ||||
-rw-r--r-- | layouts/partials/footer.html | 53 | ||||
-rw-r--r-- | layouts/partials/head.html | 91 | ||||
-rw-r--r-- | layouts/partials/header.html | 21 | ||||
-rw-r--r-- | layouts/partials/header/language-selector.html | 25 | ||||
-rw-r--r-- | layouts/partials/icons.html | 6 | ||||
-rw-r--r-- | layouts/partials/post/copyright.html | 35 | ||||
-rw-r--r-- | layouts/partials/post/outdated-info-warning.html | 28 | ||||
-rw-r--r-- | layouts/partials/post/reward.html | 21 | ||||
-rw-r--r-- | layouts/partials/post/toc.html | 9 | ||||
-rw-r--r-- | layouts/partials/scripts.html | 135 | ||||
-rw-r--r-- | layouts/partials/slideout.html | 27 |
12 files changed, 589 insertions, 0 deletions
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> |