Merge pull request #73 from dillonzq/feature/custom_fixed_header

Feature/custom fixed header
This commit is contained in:
Dillon
2020-02-16 22:43:58 +08:00
committed by GitHub
28 changed files with 434 additions and 469 deletions

32
.circleci/config.yml Normal file
View File

@@ -0,0 +1,32 @@
version: 2.1
jobs:
build-check:
parameters:
example-site-path:
type: string
theme-path:
type: string
docker:
- image: cibuilds/hugo:0.64
working_directory: ~/LoveIt
steps:
- checkout
- run: git submodule sync
- run: git submodule update --init
- run:
command: |
cd << parameters.example-site-path >>
pwd
HUGO_ENV=production hugo --themesDir << parameters.theme-path >> -v --minify --gc
htmlproofer public --allow-hash-href --empty-alt-ignore --disable-external
workflows:
build-check-exampleSite:
jobs:
- build-check:
example-site-path: exampleSite
theme-path: ../..
build-check-exampleSite-zh:
jobs:
- build-check:
example-site-path: exampleSite/zh
theme-path: ../../..

View File

@@ -91,7 +91,6 @@ I hope you will LoveIt ❤️!
* Kinds of admonitions shortcode support * Kinds of admonitions shortcode support
* Custom align and float style shortcodes support * Custom align and float style shortcodes support
* Animated typing support by [TypeIt](https://typeitjs.com/) * Animated typing support by [TypeIt](https://typeitjs.com/)
* Animated coutdown support by [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
* Dynamic to top support by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) * Dynamic to top support by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
* ... * ...
@@ -200,8 +199,6 @@ Thanks to the authors of following resources included in the theme:
* [lazysizes](https://github.com/aFarkas/lazysizes) * [lazysizes](https://github.com/aFarkas/lazysizes)
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) * [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
* [TypeIt](https://typeitjs.com/) * [TypeIt](https://typeitjs.com/)
* [jQuery](https://github.com/jquery/jquery)
* [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
* [Katex](https://katex.org/) * [Katex](https://katex.org/)
* [mermaid](https://github.com/knsv/mermaid) * [mermaid](https://github.com/knsv/mermaid)
* [APlayer](https://github.com/MoePlayer/APlayer) * [APlayer](https://github.com/MoePlayer/APlayer)

View File

@@ -86,7 +86,6 @@
* 支持多种提醒样式的 shortcode * 支持多种提醒样式的 shortcode
* 支持自定义对齐和浮动方式的 shortcode * 支持自定义对齐和浮动方式的 shortcode
* 支持基于 [TypeIt](https://typeitjs.com/) 的打字动画 * 支持基于 [TypeIt](https://typeitjs.com/) 的打字动画
* 支持基于 [jQuery.countdown](https://github.com/hilios/jQuery.countdown) 的倒计时动画
* 支持基于 [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) 的回到顶部动画 * 支持基于 [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) 的回到顶部动画
* ... * ...
@@ -135,7 +134,7 @@
* `assets/css/_varibales.scss` 你可以覆盖 `_variables.scss` 中的变量来自定义样式 * `assets/css/_varibales.scss` 你可以覆盖 `_variables.scss` 中的变量来自定义样式
* `assets/css/_custom.scss` 你可以把自定义的样式放在这个文件 * `assets/css/_custom.scss` 你可以把自定义的样式放在这个文件
* 需要使用hugo extended版本编译sass否则修改css无法生效 * 需要使用hugo extended版本编译sass否则修改css无法生效
## 网站图标、浏览器配置、网站清单 ## 网站图标、浏览器配置、网站清单
@@ -195,8 +194,6 @@ LoveIt 根据 MIT 许可协议授权。 更多信息请查看 [LICENSE 文件](h
* [lazysizes](https://github.com/aFarkas/lazysizes) * [lazysizes](https://github.com/aFarkas/lazysizes)
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) * [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
* [TypeIt](https://typeitjs.com/) * [TypeIt](https://typeitjs.com/)
* [jQuery](https://github.com/jquery/jquery)
* [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
* [Katex](https://katex.org/) * [Katex](https://katex.org/)
* [mermaid](https://github.com/knsv/mermaid) * [mermaid](https://github.com/knsv/mermaid)
* [APlayer](https://github.com/MoePlayer/APlayer) * [APlayer](https://github.com/MoePlayer/APlayer)

View File

@@ -1,5 +1,6 @@
html { html {
font-family: $global-font-family; font-family: $global-font-family;
font-size: 16px;
} }
/* scrollbar, only support webkit */ /* scrollbar, only support webkit */
@@ -25,7 +26,6 @@ html {
} }
body { body {
font-size: 16px;
font-weight: 400; font-weight: 400;
line-height: 1.5rem; line-height: 1.5rem;
background-color: $global-background-color; background-color: $global-background-color;

View File

@@ -32,7 +32,7 @@
} }
@media only screen and (max-width: 960px) { @media only screen and (max-width: 960px) {
header.desktop { #header-desktop {
.header-wrapper { .header-wrapper {
margin: 0 1rem; margin: 0 1rem;
} }
@@ -52,16 +52,17 @@
} }
@media only screen and (max-width: 560px) { @media only screen and (max-width: 560px) {
header.desktop { #header-desktop {
display: none; display: none;
} }
header.mobile { #header-mobile {
display: block; display: block;
} }
.page { .page {
max-width: 100%; max-width: 100%;
padding-top: $page-padding-top-mobile;
.categories-card { .categories-card {
.card-item { .card-item {
@@ -80,8 +81,4 @@
} }
} }
} }
.dynamic-to-top {
display: none !important;
}
} }

View File

@@ -3,7 +3,7 @@
width: 100%; width: 100%;
max-width: 980px; max-width: 980px;
margin: 0 auto; margin: 0 auto;
padding-top: 6rem; padding-top: $page-padding-top-desktop;
} }
@import "_single"; @import "_single";

View File

@@ -54,13 +54,6 @@
@import "../_partial/_single/toc"; @import "../_partial/_single/toc";
.content { .content {
.post-dummy-target:target {
display: inline-block;
position: relative;
top: -5.6rem;
visibility: hidden;
}
h1, h1,
h2, h2,
h3, h3,
@@ -68,22 +61,14 @@
h5, h5,
h6 { h6 {
font-weight: bold; font-weight: bold;
margin: 1.2rem 0;
.dark-theme & { .dark-theme & {
font-weight: bolder; font-weight: bolder;
} }
} }
h2, h2 > a:first-child::before {
h3,
h4,
h5,
h6 {
padding-top: .8rem;
padding-bottom: .3rem;
}
h2::before {
content: "#"; content: "#";
margin-right: .3125rem; margin-right: .3125rem;
color: $single-link-color; color: $single-link-color;
@@ -93,16 +78,18 @@
} }
} }
h3::before, h3,
h4::before, h4,
h5::before, h5,
h6::before { h6 {
content: "|"; & > a:first-child::before {
margin-right: .3125rem; content: "|";
color: $single-link-color; margin-right: .3125rem;
color: $single-link-color;
.dark-theme & { .dark-theme & {
color: $single-link-color-dark; color: $single-link-color-dark;
}
} }
} }

View File

@@ -1,15 +1,18 @@
header.desktop { header {
display: block;
position: fixed;
width: 100%; width: 100%;
z-index: 100; z-index: 100;
height: 4rem;
line-height: 4rem;
background-color: $header-background-color; background-color: $header-background-color;
.dark-theme & { .dark-theme & {
background-color: $header-background-color-dark; background-color: $header-background-color-dark;
} }
}
#header-desktop {
display: block;
position: $header-position-desktop;
height: $header-height-desktop;
line-height: $header-height-desktop;
.header-wrapper { .header-wrapper {
width: auto; width: auto;
@@ -42,19 +45,16 @@ header.desktop {
} }
} }
header.mobile { #header-mobile {
display: none; display: none;
position: fixed; position: $header-position-mobile;
width: 100%; height: $header-height-mobile;
z-index: 100; line-height: $header-height-mobile;
transition: all 0.3s ease 0s;
.header-wrapper { .header-wrapper {
padding: 0; padding: 0;
margin: 0; margin: 0;
height: 4.5rem; transition: all 0.3s ease 0s;
line-height: 4.5rem;
background: $global-background-color;
.header-container { .header-container {
display: flex; display: flex;
@@ -72,19 +72,19 @@ header.mobile {
.menu-toggle { .menu-toggle {
cursor: pointer; cursor: pointer;
line-height: 4.5rem; line-height: 4rem;
span { span {
display: block; display: block;
background: #000; background: $global-font-color;
width: 24px; width: 1.5rem;
height: 2px; height: 2px;
-webkit-border-radius: 3px; -webkit-border-radius: 3px;
-moz-border-radius: 3px; -moz-border-radius: 3px;
border-radius: 3px; border-radius: 3px;
-webkit-transition: .2s margin .2s, .2s transform; -webkit-transition: .1s margin .1s, .1s transform;
-moz-transition: .2s margin .2s, .2s transform; -moz-transition: .1s margin .1s, .1s transform;
transition: .2s margin .2s, .2s transform; transition: .1s margin .1s, .1s transform;
.dark-theme & { .dark-theme & {
background: $global-font-color-dark; background: $global-font-color-dark;
@@ -92,25 +92,25 @@ header.mobile {
} }
span:nth-child(1) { span:nth-child(1) {
margin-bottom: 8px; margin-bottom: .5rem;
} }
span:nth-child(3) { span:nth-child(3) {
margin-top: 8px; margin-top: .5rem;
} }
&.active { &.active {
span { span {
-webkit-transition: .2s margin, .2s transform .2s; -webkit-transition: .1s margin, .1s transform .1s;
-moz-transition: .2s margin, .2s transform .2s; -moz-transition: .1s margin, .1s transform .1s;
transition: .2s margin, .2s transform .2s; transition: .1s margin, .1s transform .1s;
} }
span:nth-child(1) { span:nth-child(1) {
-moz-transform: rotate(45deg) translate(4px, 6px); -moz-transform: rotate(45deg) translate(.4rem, .5rem);
-ms-transform: rotate(45deg) translate(4px, 6px); -ms-transform: rotate(45deg) translate(.4rem, .5rem);
-webkit-transform: rotate(45deg) translate(4px, 6px); -webkit-transform: rotate(45deg) translate(.4rem, .5rem);
transform: rotate(45deg) translate(4px, 6px); transform: rotate(45deg) translate(.4rem, .5rem);
} }
span:nth-child(2) { span:nth-child(2) {
@@ -118,10 +118,10 @@ header.mobile {
} }
span:nth-child(3) { span:nth-child(3) {
-moz-transform: rotate(-45deg) translate(8px, -10px); -moz-transform: rotate(-45deg) translate(.4rem, -.5rem);
-ms-transform: rotate(-45deg) translate(8px, -10px); -ms-transform: rotate(-45deg) translate(.4rem, -.5rem);
-webkit-transform: rotate(-45deg) translate(8px, -10px); -webkit-transform: rotate(-45deg) translate(.4rem, -.5rem);
transform: rotate(-45deg) translate(8px, -10px); transform: rotate(-45deg) translate(.4rem, -.5rem);
} }
} }
} }
@@ -148,9 +148,5 @@ header.mobile {
border-top: 2px solid $global-font-color-dark; border-top: 2px solid $global-font-color-dark;
} }
} }
.dark-theme & {
background: $global-background-color-dark;
}
} }
} }

View File

@@ -7,7 +7,7 @@
border-left: 1px solid $global-border-color; border-left: 1px solid $global-border-color;
overflow-wrap: break-word; overflow-wrap: break-word;
box-sizing: border-box; box-sizing: border-box;
top: 12rem; top: $post-toc-top;
.dark-theme & { .dark-theme & {
border-left: 1px solid $global-border-color-dark; border-left: 1px solid $global-border-color-dark;
@@ -54,16 +54,15 @@
} }
} }
.toc-link.active { a.active {
font-weight: bold; font-weight: bold;
color: $single-link-hover-color; color: $single-link-color;
.dark-theme & { .dark-theme & {
color: $single-link-hover-color-dark; color: $single-link-color-dark;
} }
&::before { &::before {
font-weight: bolder;
color: $single-link-hover-color; color: $single-link-hover-color;
.dark-theme & { .dark-theme & {

View File

@@ -1,5 +1,3 @@
@charset 'utf-8';
// ============================== // ==============================
// Variables // Variables
// ============================== // ==============================
@@ -48,6 +46,10 @@ $selection-color-dark: rgba(38, 139, 211, 0.3) !default;
// ========== Selection ========== // // ========== Selection ========== //
// ========== Header ========== // // ========== Header ========== //
// Height of the header
$header-height-desktop: 4rem !default;
$header-height-mobile: 4rem !default;
// Color of the header background // Color of the header background
$header-background-color: #fafafa !default; $header-background-color: #fafafa !default;
$header-background-color-dark: #252627 !default; $header-background-color-dark: #252627 !default;

View File

@@ -1,3 +1,5 @@
@charset 'utf-8';
{{- if eq .Site.Params.home_mode "post" -}} {{- if eq .Site.Params.home_mode "post" -}}
$home-profile: true; $home-profile: true;
$home-posts: true; $home-posts: true;
@@ -6,6 +8,24 @@
$home-posts: false; $home-posts: false;
{{- end -}} {{- end -}}
{{- if eq .Site.Params.desktopHeaderMode "normal" -}}
$header-position-desktop: static;
$page-padding-top-desktop: 1rem;
$post-toc-top: 7rem;
{{- else -}}
$header-position-desktop: fixed;
$page-padding-top-desktop: 6rem;
$post-toc-top: 12rem;
{{- end -}}
{{- if eq .Site.Params.mobileHeaderMode "normal" -}}
$header-position-mobile: static;
$page-padding-top-mobile: 1rem;
{{- else -}}
$header-position-mobile: fixed;
$page-padding-top-mobile: 6rem;
{{- end -}}
@import "_variables"; @import "_variables";
{{- if fileExists "config/css/_custom.scss" -}} {{- if fileExists "config/css/_custom.scss" -}}

View File

@@ -1,12 +1,10 @@
gitalk@1.5.0 gitalk@1.5.0
valine@1.3.10 valine@1.3.10
jquery@3.4.1
lazysizes@5.1.2 lazysizes@5.1.2
katex@0.11.1 katex@0.11.1
mermaid@8.4.2 mermaid@8.4.2
echarts@4.5.0 echarts@4.5.0
typeit@6.0.3 typeit@6.5.1
jquery-countdown@2.2.0
aplayer@1.10.1 aplayer@1.10.1
meting@2.0.1 meting@2.0.1
smooth-scroll@16.1.0 smooth-scroll@16.1.2

View File

@@ -1,22 +0,0 @@
/*!
* The Final Countdown for jQuery v2.2.0 (http://hilios.github.io/jQuery.countdown/)
* Copyright (c) 2016 Edson Hilios
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){"use strict";function b(a){if(a instanceof Date)return a;if(String(a).match(g))return String(a).match(/^[0-9]*$/)&&(a=Number(a)),String(a).match(/\-/)&&(a=String(a).replace(/\-/g,"/")),new Date(a);throw new Error("Couldn't cast `"+a+"` to a date object.")}function c(a){var b=a.toString().replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");return new RegExp(b)}function d(a){return function(b){var d=b.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi);if(d)for(var f=0,g=d.length;f<g;++f){var h=d[f].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/),j=c(h[0]),k=h[1]||"",l=h[3]||"",m=null;h=h[2],i.hasOwnProperty(h)&&(m=i[h],m=Number(a[m])),null!==m&&("!"===k&&(m=e(l,m)),""===k&&m<10&&(m="0"+m.toString()),b=b.replace(j,m.toString()))}return b=b.replace(/%%/,"%")}}function e(a,b){var c="s",d="";return a&&(a=a.replace(/(:|;|\s)/gi,"").split(/\,/),1===a.length?c=a[0]:(d=a[0],c=a[1])),Math.abs(b)>1?c:d}var f=[],g=[],h={precision:100,elapse:!1,defer:!1};g.push(/^[0-9]*$/.source),g.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source),g.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source),g=new RegExp(g.join("|"));var i={Y:"years",m:"months",n:"daysToMonth",d:"daysToWeek",w:"weeks",W:"weeksToMonth",H:"hours",M:"minutes",S:"seconds",D:"totalDays",I:"totalHours",N:"totalMinutes",T:"totalSeconds"},j=function(b,c,d){this.el=b,this.$el=a(b),this.interval=null,this.offset={},this.options=a.extend({},h),this.instanceNumber=f.length,f.push(this),this.$el.data("countdown-instance",this.instanceNumber),d&&("function"==typeof d?(this.$el.on("update.countdown",d),this.$el.on("stoped.countdown",d),this.$el.on("finish.countdown",d)):this.options=a.extend({},h,d)),this.setFinalDate(c),this.options.defer===!1&&this.start()};a.extend(j.prototype,{start:function(){null!==this.interval&&clearInterval(this.interval);var a=this;this.update(),this.interval=setInterval(function(){a.update.call(a)},this.options.precision)},stop:function(){clearInterval(this.interval),this.interval=null,this.dispatchEvent("stoped")},toggle:function(){this.interval?this.stop():this.start()},pause:function(){this.stop()},resume:function(){this.start()},remove:function(){this.stop.call(this),f[this.instanceNumber]=null,delete this.$el.data().countdownInstance},setFinalDate:function(a){this.finalDate=b(a)},update:function(){if(0===this.$el.closest("html").length)return void this.remove();var b,c=void 0!==a._data(this.el,"events"),d=new Date;b=this.finalDate.getTime()-d.getTime(),b=Math.ceil(b/1e3),b=!this.options.elapse&&b<0?0:Math.abs(b),this.totalSecsLeft!==b&&c&&(this.totalSecsLeft=b,this.elapsed=d>=this.finalDate,this.offset={seconds:this.totalSecsLeft%60,minutes:Math.floor(this.totalSecsLeft/60)%60,hours:Math.floor(this.totalSecsLeft/60/60)%24,days:Math.floor(this.totalSecsLeft/60/60/24)%7,daysToWeek:Math.floor(this.totalSecsLeft/60/60/24)%7,daysToMonth:Math.floor(this.totalSecsLeft/60/60/24%30.4368),weeks:Math.floor(this.totalSecsLeft/60/60/24/7),weeksToMonth:Math.floor(this.totalSecsLeft/60/60/24/7)%4,months:Math.floor(this.totalSecsLeft/60/60/24/30.4368),years:Math.abs(this.finalDate.getFullYear()-d.getFullYear()),totalDays:Math.floor(this.totalSecsLeft/60/60/24),totalHours:Math.floor(this.totalSecsLeft/60/60),totalMinutes:Math.floor(this.totalSecsLeft/60),totalSeconds:this.totalSecsLeft},this.options.elapse||0!==this.totalSecsLeft?this.dispatchEvent("update"):(this.stop(),this.dispatchEvent("finish")))},dispatchEvent:function(b){var c=a.Event(b+".countdown");c.finalDate=this.finalDate,c.elapsed=this.elapsed,c.offset=a.extend({},this.offset),c.strftime=d(this.offset),this.$el.trigger(c)}}),a.fn.countdown=function(){var b=Array.prototype.slice.call(arguments,0);return this.each(function(){var c=a(this).data("countdown-instance");if(void 0!==c){var d=f[c],e=b[0];j.prototype.hasOwnProperty(e)?d[e].apply(d,b.slice(1)):null===String(e).match(/^[$A-Z_][0-9A-Z_$]*$/i)?(d.setFinalDate.call(d,e),d.start()):a.error("Method %s does not exist on jQuery.countdown".replace(/\%s/gi,e))}else new j(this,b[0],b[1])})}});

File diff suppressed because one or more lines are too long

4
assets/js/lib/smooth-scroll/smooth-scroll.polyfills.min.js vendored Normal file → Executable file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,313 +1,320 @@
jQuery(function($) { (() => {
'use strict'; 'use strict';
var _Theme = window._Theme || {}; class Util {
forEach(elements, handler) {
elements = elements || [];
for (let i = 0; i < elements.length; i++) {
handler(elements[i]);
}
}
_Theme.scroll = function () { getScrollTop() {
window.scroll = new SmoothScroll('[data-scroll]', {speed: 300, speedAsDuration: true}); return (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
}
} }
_Theme.toggleMobileMenu = function () { class Theme {
$('#menu-toggle').on('click', () => { constructor() {
$('#menu-toggle').toggleClass('active'); this.util = new Util();
$('#menu-mobile').toggleClass('active'); this.scrollTop = 0;
}); this.scrollEvents = [];
}; }
_Theme.toggleTheme = function () { initMobileMenu() {
$('.theme-switch').on('click', () => { document.getElementById('menu-toggle').onclick = () => {
$('body').toggleClass('dark-theme'); document.getElementById('menu-toggle').classList.toggle('active');
window.isDark = !window.isDark; document.getElementById('menu-mobile').classList.toggle('active');
window.localStorage && window.localStorage.setItem('theme', window.isDark ? 'dark' : 'light'); };
this.echarts(); }
});
};
_Theme.dynamicToTop = function () { initSwitchTheme() {
const min = 300; this.util.forEach(document.getElementsByClassName('theme-switch'), (button) => {
var $toTop = $('#dynamic-to-top'); button.onclick = () => {
$(window).scroll(() => { document.body.classList.toggle('dark-theme');
var scrollTop = $(window).scrollTop(); window.isDark = !window.isDark;
if (typeof document.body.style.maxHeight === 'undefined') { window.localStorage && window.localStorage.setItem('theme', window.isDark ? 'dark' : 'light');
$toTop.css({ this.initEcharts();
'position': 'absolute', };
'top': scrollTop + $(window).height() - 20, });
}
initHighlight() {
this.util.forEach(document.querySelectorAll('.highlight > .chroma'), (block) => {
const codes = block.querySelectorAll('pre.chroma > code');
const code = codes[codes.length - 1];
const lang = code ? code.className.toLowerCase() : '';
block.className += ' ' + lang;
});
this.util.forEach(document.querySelectorAll('.highlight > pre.chroma'), (block) => {
const chroma = document.createElement('div');
chroma.className = block.className;
const table = document.createElement('table');
chroma.appendChild(table);
const tbody = document.createElement('tbody');
table.appendChild(tbody);
const tr = document.createElement('tr');
tbody.appendChild(tr);
const td = document.createElement('td');
tr.appendChild(td);
block.parentElement.replaceChild(chroma, block);
td.appendChild(block);
});
}
initTable() {
this.util.forEach(document.querySelectorAll('.content table'), (table) => {
const wrapper = document.createElement('div');
wrapper.className = 'table-wrapper';
table.parentElement.replaceChild(wrapper, table);
wrapper.appendChild(table);
});
}
initHeaderLink() {
for (let num = 1; num <= 6; num++) {
this.util.forEach(document.querySelectorAll('.content > h' + num), (header) => {
header.classList.add('headerLink');
header.innerHTML = `<a href="#${header.id}"></a>${header.innerHTML}`;
}); });
} }
if (scrollTop > min) { }
(function fadeIn(el, display){
display = display || "block"; _refactorToc(toc) {
if (el.style.display !== display) { this.util.forEach(toc.querySelectorAll('a:first-child'), (link) => {
el.style.opacity = 0; link.classList.add('toc-link');
el.style.display = display; });
(function fade() {
var val = parseFloat(el.style.opacity); // when headings do not start with `h1`
if (!((val += .1) > 1)) { const oldTocList = toc.children[0];
el.style.opacity = val; let newTocList = oldTocList;
requestAnimationFrame(fade); let temp;
} while (newTocList.children.length === 1
})(); && (temp = newTocList.children[0].children[0]).tagName === 'UL') {
} newTocList = temp;
})(document.getElementById('dynamic-to-top'));
} else {
(function fadeOut(el){
if (el.style.display !== "none") {
el.style.opacity = 1;
(function fade() {
if ((el.style.opacity -= .1) < 0) {
el.style.display = "none";
} else {
requestAnimationFrame(fade);
}
})();
}
})(document.getElementById('dynamic-to-top'));
} }
}); if (newTocList !== oldTocList) toc.replaceChild(newTocList, oldTocList);
};
_Theme.chroma = function () {
const blocks = document.querySelectorAll('.highlight > .chroma');
for (let i = 0; i < blocks.length; i++) {
const block = blocks[i];
const codes = block.querySelectorAll('pre.chroma > code');
const code = codes[codes.length - 1];
const lang = code ? code.className.toLowerCase() : '';
block.className += ' ' + lang;
} }
const nolinenosBlocks = document.querySelectorAll('.highlight > pre.chroma'); _initTocState(tocContainer) {
for (let i = 0; i < nolinenosBlocks.length; i++) { if (window.getComputedStyle(tocContainer, null).display !== 'none') {
const block = nolinenosBlocks[i]; const fixed = window.desktopHeaderMode !== 'normal';
const chroma = document.createElement('div'); const fixedHeight = document.getElementById('header-desktop').getBoundingClientRect().height;
chroma.className = block.className; const TOP_SPACING = 20 + (fixed ? fixedHeight : 0);
const table = document.createElement('table'); const minTop = tocContainer.offsetTop;
chroma.appendChild(table); const minScrollTop = minTop - TOP_SPACING + (fixed ? 0 : fixedHeight);
const tbody = document.createElement('tbody'); const footerTop = document.getElementById('post-footer').offsetTop;
table.appendChild(tbody); const toclinks = tocContainer.getElementsByClassName('toc-link');
const tr = document.createElement('tr'); const headerLinks = document.getElementsByClassName('headerLink') || [];
tbody.appendChild(tr); const tocLinkLis = tocContainer.querySelectorAll('.post-toc-content li');
const td = document.createElement('td'); const INDEX_SPACING = 5 + (fixed ? fixedHeight : 0);
tr.appendChild(td);
block.parentElement.replaceChild(chroma, block);
td.appendChild(block);
}
};
_Theme.responsiveTable = function () { const changeTocState = () => {
const tables = document.querySelectorAll('.content table'); const scrollTop = this.util.getScrollTop();
for (let i = 0; i < tables.length; i++) { const maxTop = footerTop - tocContainer.getBoundingClientRect().height;
const table = tables[i]; const maxScrollTop = maxTop - TOP_SPACING + (fixed ? 0 : fixedHeight);
const wrapper = document.createElement('div'); if (scrollTop < minScrollTop) {
wrapper.className = 'table-wrapper'; tocContainer.style.position = 'absolute';
table.parentElement.replaceChild(wrapper, table); tocContainer.style.top = `${minTop}px`;
wrapper.appendChild(table); } else if (scrollTop > maxScrollTop) {
} tocContainer.style.position = 'absolute';
}; tocContainer.style.top = `${maxTop}px`;
} else {
tocContainer.style.position = 'fixed';
tocContainer.style.top = `${TOP_SPACING}px`;
}
_Theme._refactorToc = function(toc) { this.util.forEach(toclinks, (link) => { link.classList.remove('active'); });
// when headings do not start with `h1` this.util.forEach(tocLinkLis, (link) => { link.classList.remove('has-active'); });
const oldTocList = toc.children[0]; let activeTocIndex = headerLinks.length - 1;
let newTocList = oldTocList; for (let i = 0; i < headerLinks.length - 1; i++) {
let temp; const thisTop = headerLinks[i].getBoundingClientRect().top;
while (newTocList.children.length === 1 const nextTop = headerLinks[i + 1].getBoundingClientRect().top;
&& (temp = newTocList.children[0].children[0]).tagName === 'UL') { if ((i == 0 && thisTop > INDEX_SPACING)
newTocList = temp; || (thisTop <= INDEX_SPACING && nextTop > INDEX_SPACING)) {
} activeTocIndex = i;
if (newTocList !== oldTocList) toc.replaceChild(newTocList, oldTocList); break;
}; }
}
_Theme._linkToc = function () { if (activeTocIndex !== -1) {
const links = document.querySelectorAll('#TableOfContents a:first-child'); toclinks[activeTocIndex].classList.add('active');
for (let i = 0; i < links.length; i++) links[i].className += ' toc-link'; let parent = toclinks[activeTocIndex].parentElement;
while (parent.tagName !== 'NAV') {
for (let num = 1; num <= 6; num++) { parent.classList.add('has-active');
const headers = document.querySelectorAll('.content>h' + num); parent = parent.parentElement.parentElement;
for (let i = 0; i < headers.length; i++) { }
const header = headers[i];
header.innerHTML = `<a href="#${header.id}" class="headerlink"></a>${header.innerHTML}`;
}
}
};
_Theme._initToc = function () {
const $toc = $('#post-toc');
if ($toc.length && $toc.css('display') !== 'none') {
const SPACING = 80;
const $footer = $('#post-footer');
const minTop = $toc.position().top;;
const mainTop = $('main').position().top;
const minScrollTop = minTop + mainTop - SPACING;
const changeTocState = function () {
const scrollTop = $(window).scrollTop();
const maxTop = $footer.position().top - $toc.height();
const maxScrollTop = maxTop + mainTop - SPACING;
const tocState = {
start: {
'position': 'absolute',
'top': minTop,
},
process: {
'position': 'fixed',
'top': SPACING,
},
end: {
'position': 'absolute',
'top': maxTop,
} }
}; };
changeTocState();
if (scrollTop < minScrollTop) { if (!this._initTocOnce) {
$toc.css(tocState.start); this.scrollEvents.push(changeTocState);
} else if (scrollTop > maxScrollTop) { this._initTocOnce = true;
$toc.css(tocState.end); }
}
}
initToc() {
const tocContainer = document.getElementById('post-toc');
if (tocContainer !== null) {
const toc = document.getElementById('TableOfContents');
if (toc === null) {
tocContainer.parentElement.removeChild(tocContainer);
} else { } else {
$toc.css(tocState.process); this._refactorToc(toc);
this._initTocState(tocContainer);
window.addEventListener('resize', () => {
window.setTimeout(() => {
this._initTocState(tocContainer);
}, 0);
}, false);
} }
};
changeTocState();
const $toclink = $('.toc-link');
const $headerDummyLink = $('.post-dummy-target');
const $tocLinkLis = $('.post-toc-content li');
const activeIndex = function () {
const scrollTop = $(window).scrollTop();
const headerlinkTop = $.map($headerDummyLink, function(link) {
return $(link).offset().top;
});
const searchActiveTocIndex = function(array, target) {
for (let i = 0; i < array.length - 1; i++) {
if ( target < array[i + 1]) return i;
}
return array.length - 1;
};
const activeTocIndex = searchActiveTocIndex(headerlinkTop, scrollTop);
$($toclink).removeClass('active');
$($tocLinkLis).removeClass('has-active');
if (activeTocIndex !== -1) {
$($toclink[activeTocIndex]).addClass('active');
let ancestor = $toclink[activeTocIndex].parentNode;
while (ancestor.tagName !== 'NAV') {
$(ancestor).addClass('has-active');
ancestor = ancestor.parentNode.parentNode;
}
}
};
activeIndex();
if (!this._initTocOnce) {
$(window).scroll(changeTocState);
$(window).scroll(activeIndex);
this._initTocOnce = true;
} }
} }
};
_Theme.toc = function () { initMermaid() {
const tocContainer = document.getElementById('post-toc'); if (window.mermaidMap) {
if (tocContainer !== null) { mermaid.initialize({startOnLoad: false, theme: null});
const toc = document.getElementById('TableOfContents'); Object.keys(mermaidMap).forEach((id) => {
if (toc === null) { const element = document.getElementById(id);
// toc = true, but there are no headings mermaid.mermaidAPI.render("d" + id, mermaidMap[id], (svgCode) => {
tocContainer.parentNode.removeChild(tocContainer); element.innerHTML = svgCode;
} else { const svg = element.firstChild;
this._refactorToc(toc); svg.style.width = "100%"
this._linkToc(); }, element);
this._initToc(); });
// Listen for orientation changes }
}
initEcharts() {
if (window.echartsMap) {
for (let i = 0; i < echartsArr.length; i++) {
echartsArr[i].dispose();
}
echartsArr = [];
Object.keys(echartsMap).forEach((id) => {
let myChart = echarts.init(document.getElementById(id), window.isDark ? 'dark' : 'macarons', {renderer: 'svg'});
myChart.setOption(echartsMap[id]);
echartsArr.push(myChart);
});
window.addEventListener("resize", function () { window.addEventListener("resize", function () {
this.setTimeout(_Theme._initToc, 0); this.setTimeout(() => {
for (let i = 0; i < echartsArr.length; i++) {
echartsArr[i].resize();
}
}, 0);
}, false); }, false);
} }
} }
};
_Theme.mermaid = function () { initTypeit() {
if (window.mermaidMap) { if (window.typeitArr) {
mermaid.initialize({startOnLoad: false, theme: null}); for (let i = 0; i < typeitArr.length; i++) {
const mermaidAPI = mermaid.mermaidAPI const group = typeitArr[i];
Object.keys(mermaidMap).forEach((id) => { (function typeone(i) {
const element = document.getElementById(id); const content = document.getElementById(`r${group[i]}`).innerHTML;
mermaidAPI.render("d" + id, mermaidMap[id], (svgCode) => { if (i === group.length - 1) {
element.innerHTML = svgCode; new TypeIt(`#${group[i]}`, {
const svg = element.firstChild; strings: content,
svg.style.width = "100%" }).go();
}, element); return;
}); }
} let instance = new TypeIt(`#${group[i]}`, {
} strings: content,
afterComplete: () => {
_Theme.echarts = function () { instance.destroy();
if (window.echartsMap) { typeone(i + 1);
for (let i = 0; i < echartsArr.length; i++) { },
echartsArr[i].dispose(); }).go();
})(0);
}
} }
echartsArr = []; }
Object.keys(echartsMap).forEach((id) => {
let myChart = echarts.init(document.getElementById(id), window.isDark ? 'dark' : 'macarons', {renderer: 'svg'}); initScroll() {
myChart.setOption(echartsMap[id]); for (let i = 0; i < this.scrollEvents.length; i++) {
echartsArr.push(myChart); document.addEventListener('scroll', this.scrollEvents[i], false);
}); }
window.addEventListener("resize", function () { const initSmoothScroll = () => {
this.setTimeout(() => { const isMobile = window.matchMedia('only screen and (max-width: 560px)').matches;
for (let i = 0; i < echartsArr.length; i++) { if ((!isMobile && window.desktopHeaderMode === 'normal')
echartsArr[i].resize(); || (isMobile && window.mobileHeaderMode === 'normal')) {
} new SmoothScroll('[href^="#"]', {speed: 300, speedAsDuration: true});
} else {
new SmoothScroll('[href^="#"]', {speed: 300, speedAsDuration: true, header: '#header-desktop'});
}
};
initSmoothScroll();
window.addEventListener('resize', () => {
window.setTimeout(() => {
initSmoothScroll();
}, 0); }, 0);
}, false); }, false);
const headers = [];
if (window.desktopHeaderMode === 'auto') headers.push(document.getElementById('header-desktop'));
if (window.mobileHeaderMode === 'auto') headers.push(document.getElementById('header-mobile'));
this.util.forEach(headers, (header) => {
header.classList.add('animated');
header.classList.add('faster');
});
const toTopButton = document.getElementById('dynamic-to-top');
document.addEventListener('scroll', () => {
const scrollTop = this.util.getScrollTop();
this.util.forEach(headers, (header) => {
if (this.scrollTop < scrollTop) {
if (!header.classList.contains('fadeOutUp')) {
header.classList.remove('fadeInDown');
header.classList.add('fadeOutUp');
}
} else {
if (!header.classList.contains('fadeInDown')) {
header.classList.remove('fadeOutUp');
header.classList.add('fadeInDown');
}
}
if (scrollTop > 600) {
if (this.scrollTop < scrollTop) {
if (!toTopButton.classList.contains('fadeOut')) {
toTopButton.classList.remove('fadeIn');
toTopButton.classList.add('fadeOut');
}
} else {
toTopButton.style.display = 'block';
if (!toTopButton.classList.contains('fadeIn')) {
toTopButton.classList.remove('fadeOut');
toTopButton.classList.add('fadeIn');
}
}
} else {
toTopButton.style.display = 'none';
}
});
this.scrollTop = scrollTop;
}, false);
}
init() {
this.initMobileMenu();
this.initSwitchTheme();
this.initHighlight();
this.initTable();
this.initHeaderLink();
this.initMermaid();
this.initEcharts();
this.initTypeit();
this.initToc();
this.initScroll();
} }
} }
_Theme.countdown = function () { const themeInit = () => {
if (window.countdownMap) { const theme = new Theme();
Object.keys(countdownMap).forEach(function(id) { theme.init();
$(`#${id}`).countdown(countdownMap[id]['date'], {elapse: true})
.on('update.countdown', function(event) {
$(this).html(event.strftime(countdownMap[id]['pattern']));
});
});
}
}; };
_Theme.typeit = function () { if (document.readyState !== 'loading') {
if (window.typeitArr) { themeInit();
for (let i = 0; i < typeitArr.length; i++) { } else {
const group = typeitArr[i]; document.addEventListener('DOMContentLoaded', themeInit, false);
(function typeone(i) { }
const content = document.getElementById(`r${group[i]}`).innerHTML; })();
if (i === group.length - 1) {
new TypeIt(`#${group[i]}`, {
strings: content,
}).go();
return;
}
let instance = new TypeIt(`#${group[i]}`, {
strings: content,
afterComplete: () => {
instance.destroy();
typeone(i + 1);
},
}).go();
})(0);
}
}
};
$(document).ready(() => {
_Theme.scroll();
_Theme.toggleMobileMenu();
_Theme.toggleTheme();
_Theme.dynamicToTop();
_Theme.chroma();
_Theme.responsiveTable();
_Theme.mermaid();
_Theme.echarts();
_Theme.countdown();
_Theme.typeit();
_Theme.toc();
});
});

View File

@@ -112,6 +112,10 @@ dateFormatToUse = "2006-01-02"
keywords = ["Theme", "Hugo"] keywords = ["Theme", "Hugo"]
# site default theme ("light", "dark", "auto") # site default theme ("light", "dark", "auto")
defaultTheme = "auto" defaultTheme = "auto"
# desktop header mode ("fixed", "normal", "auto")
desktopHeaderMode = "fixed"
# mobile header mode ("fixed", "normal", "auto")
mobileHeaderMode = "auto"
# Home Page Info # Home Page Info
##home mode ("post", "other") ##home mode ("post", "other")
@@ -167,7 +171,6 @@ dateFormatToUse = "2006-01-02"
gitalk_css = '' gitalk_css = ''
gitalk_js = '' gitalk_js = ''
valine_js = '' valine_js = ''
jquery_js = ''
lazysizes_js = '' lazysizes_js = ''
smooth_scroll_js = '' smooth_scroll_js = ''
katex_css = '' katex_css = ''
@@ -180,7 +183,6 @@ dateFormatToUse = "2006-01-02"
echarts_js = '' echarts_js = ''
echarts_macarons_js = '' echarts_macarons_js = ''
typeit_js = '' typeit_js = ''
jquery_countdown_js = ''
aplayer_css = '' aplayer_css = ''
aplayer_js = '' aplayer_js = ''
meting_js = '' meting_js = ''

View File

@@ -52,7 +52,6 @@ It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt/) a
* :(far fa-bell): Kinds of admonitions shortcode support * :(far fa-bell): Kinds of admonitions shortcode support
* :(fas fa-align-left): Custom align and float style shortcodes support * :(fas fa-align-left): Custom align and float style shortcodes support
* :(fas fa-i-cursor): Animated typing support by [TypeIt](https://typeitjs.com/) * :(fas fa-i-cursor): Animated typing support by [TypeIt](https://typeitjs.com/)
* :(far fa-clock): Animated coutdown support by [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
* :(fas fa-arrow-up): Dynamic to top support by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) * :(fas fa-arrow-up): Dynamic to top support by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
* ... * ...
@@ -69,8 +68,6 @@ Thanks to the authors of following resources included in the theme:
* [lazysizes](https://github.com/aFarkas/lazysizes) * [lazysizes](https://github.com/aFarkas/lazysizes)
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) * [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
* [TypeIt](https://typeitjs.com/) * [TypeIt](https://typeitjs.com/)
* [jQuery](https://github.com/jquery/jquery)
* [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
* [Katex](https://katex.org/) * [Katex](https://katex.org/)
* [mermaid](https://github.com/knsv/mermaid) * [mermaid](https://github.com/knsv/mermaid)
* [APlayer](https://github.com/MoePlayer/APlayer) * [APlayer](https://github.com/MoePlayer/APlayer)

View File

@@ -112,6 +112,10 @@ dateFormatToUse = "2006-01-02"
keywords = ["Theme", "Hugo"] keywords = ["Theme", "Hugo"]
# 网站默认主题 ("light", "dark", "auto") # 网站默认主题 ("light", "dark", "auto")
defaultTheme = "auto" defaultTheme = "auto"
# 桌面端导航栏模式 ("fixed", "normal", "auto")
desktopHeaderMode = "fixed"
# 移动端导航栏模式 ("fixed", "normal", "auto")
mobileHeaderMode = "auto"
# 主页信息设置 # 主页信息设置
## 主页模式 ("post", "other") ## 主页模式 ("post", "other")
@@ -167,7 +171,6 @@ dateFormatToUse = "2006-01-02"
gitalk_css = '' gitalk_css = ''
gitalk_js = '' gitalk_js = ''
valine_js = '' valine_js = ''
jquery_js = ''
lazysizes_js = '' lazysizes_js = ''
smooth_scroll_js = '' smooth_scroll_js = ''
katex_css = '' katex_css = ''
@@ -180,7 +183,6 @@ dateFormatToUse = "2006-01-02"
echarts_js = '' echarts_js = ''
echarts_macarons_js = '' echarts_macarons_js = ''
typeit_js = '' typeit_js = ''
jquery_countdown_js = ''
aplayer_css = '' aplayer_css = ''
aplayer_js = '' aplayer_js = ''
meting_js = '' meting_js = ''

View File

@@ -52,7 +52,6 @@ draft: false
* :(far fa-bell): 支持多种提醒样式的 shortcode * :(far fa-bell): 支持多种提醒样式的 shortcode
* :(fas fa-align-left): 支持自定义对齐和浮动方式的 shortcode * :(fas fa-align-left): 支持自定义对齐和浮动方式的 shortcode
* :(fas fa-i-cursor): 支持基于 [TypeIt](https://typeitjs.com/) 的打字动画 * :(fas fa-i-cursor): 支持基于 [TypeIt](https://typeitjs.com/) 的打字动画
* :(far fa-clock): 支持基于 [jQuery.countdown](https://github.com/hilios/jQuery.countdown) 的倒计时动画
* :(fas fa-arrow-up): 支持基于 [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) 的回到顶部动画 * :(fas fa-arrow-up): 支持基于 [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) 的回到顶部动画
* ... * ...
@@ -69,8 +68,6 @@ LoveIt 根据 MIT 许可协议授权。
* [lazysizes](https://github.com/aFarkas/lazysizes) * [lazysizes](https://github.com/aFarkas/lazysizes)
* [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) * [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
* [TypeIt](https://typeitjs.com/) * [TypeIt](https://typeitjs.com/)
* [jQuery](https://github.com/jquery/jquery)
* [jQuery.countdown](https://github.com/hilios/jQuery.countdown)
* [Katex](https://katex.org/) * [Katex](https://katex.org/)
* [mermaid](https://github.com/knsv/mermaid) * [mermaid](https://github.com/knsv/mermaid)
* [APlayer](https://github.com/MoePlayer/APlayer) * [APlayer](https://github.com/MoePlayer/APlayer)

View File

@@ -176,20 +176,20 @@ func main() {
### 3.5 引用链接的定义 ### 3.5 引用链接的定义
```markdown ```markdown
[foo]: /url "title" [foo]: / "title"
[foo] [foo]
[bar]: /url [bar]: /
[bar] [bar]
``` ```
[foo]: /url "title" [foo]: / "title"
[foo] [foo]
[bar]: /url [bar]: /
[bar] [bar]
@@ -683,14 +683,14 @@ function doIt() {
``` ```
| _颜色_ | 水果 | 蔬菜 | | _颜色_ | 水果 | 蔬菜 |
| ------------- |:---------------:| -----------------:| | ------------- |:---------------:| -----------------:|
| red | *苹果* | [辣椒](#Tables) | | red | *苹果* | [辣椒](#) |
| ~~橙色~~ | 橘子 | **胡萝卜** | | ~~橙色~~ | 橘子 | **胡萝卜** |
| 绿色 | ~~***梨子***~~ | 菠菜 | | 绿色 | ~~***梨子***~~ | 菠菜 |
``` ```
| _颜色_ | 水果 | 蔬菜 | | _颜色_ | 水果 | 蔬菜 |
| ------------- |:---------------:| ------------:| | ------------- |:---------------:| ------------:|
| red | *苹果* | [辣椒](#Tables) | | red | *苹果* | [辣椒](#) |
| ~~橙色~~ | 橘子 | **胡萝卜** | | ~~橙色~~ | 橘子 | **胡萝卜** |
| 绿色 | ~~***梨子***~~ | 菠菜 | | 绿色 | ~~***梨子***~~ | 菠菜 |

View File

@@ -52,7 +52,7 @@
</div> </div>
{{- /* Dynamic to top button */ -}} {{- /* Dynamic to top button */ -}}
<a href="#" class="dynamic-to-top" id="dynamic-to-top" data-scroll> <a href="#" class="dynamic-to-top animated faster" id="dynamic-to-top">
<span>&nbsp;</span> <span>&nbsp;</span>
</a> </a>

View File

@@ -1,5 +1,5 @@
{{- /* Desktop header */ -}} {{- /* Desktop header */ -}}
<header class="desktop"> <header class="desktop" id="header-desktop">
<div class="header-wrapper"> <div class="header-wrapper">
<div class="header-title animated bounceIn"> <div class="header-title animated bounceIn">
<a href="{{ .Site.BaseURL }}"> <a href="{{ .Site.BaseURL }}">
@@ -19,7 +19,7 @@
</header> </header>
{{- /* Mobile header */ -}} {{- /* Mobile header */ -}}
<header class="mobile"> <header class="mobile" id="header-mobile">
<div class="header-wrapper"> <div class="header-wrapper">
<div class="header-container"> <div class="header-container">
<div class="header-title animated bounceIn"> <div class="header-title animated bounceIn">
@@ -42,3 +42,8 @@
</div> </div>
</div> </div>
</header> </header>
<script>
window.desktopHeaderMode = {{ .Site.Params.desktopHeaderMode }};
window.mobileHeaderMode = {{ .Site.Params.mobileHeaderMode }};
</script>

View File

@@ -25,19 +25,4 @@
{{- $REout = `↩︎` -}} {{- $REout = `↩︎` -}}
{{- $content = replaceRE $REin $REout $content -}} {{- $content = replaceRE $REin $REout $content -}}
{{- /* Dummy target */ -}}
{{- $REin = `<(h[23456]) (id=".+?")>` -}}
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- /* Dummy target */ -}}
{{- $REin = `<(.+) (id="fnref:.+?")>` -}}
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- /* Dummy target */ -}}
{{- $REin = `<li (id="fn:.+?")(.*?)>\s?<p>` -}}
{{- $REout = `<li $2><p><a class="post-dummy-target" $1></a>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- return $content -}} {{- return $content -}}

View File

@@ -5,13 +5,6 @@
{{- template "_internal/google_analytics_async.html" . -}} {{- template "_internal/google_analytics_async.html" . -}}
{{- end -}} {{- end -}}
{{- /* jQuery https://github.com/jquery/jquery */ -}}
{{- with $CDN.jquery_js -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/jquery/jquery.slim.min.js" | .Scratch.Add "scriptLocal" -}}
{{- end -}}
{{- /* lazysizes https://github.com/aFarkas/lazysizes */ -}} {{- /* lazysizes https://github.com/aFarkas/lazysizes */ -}}
{{- with $CDN.lazysizes_js -}} {{- with $CDN.lazysizes_js -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}} {{- slice . | $.Scratch.Add "scriptCDN" -}}
@@ -133,18 +126,6 @@
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- /* jQuery.countdown https://github.com/hilios/jQuery.countdown */ -}}
{{- with .Scratch.Get "countdownMap" -}}
{{- with $CDN.jquery_countdown_js -}}
{{- slice . | $.Scratch.Add "scriptCDN" -}}
{{- else -}}
{{- slice "js/lib/jquery-countdown/jquery.countdown.min.js" | $.Scratch.Add "scriptLocal" -}}
{{- end -}}
<script>
window.countdownMap = {{ jsonify . | safeJS }};
</script>
{{- end -}}
{{- /* dev feature */ -}} {{- /* dev feature */ -}}
{{- if .Params.dev -}} {{- if .Params.dev -}}
{{- /* ECharts https://github.com/apache/incubator-echarts */ -}} {{- /* ECharts https://github.com/apache/incubator-echarts */ -}}

View File

@@ -1,12 +0,0 @@
{{- if .Get "date" -}}
{{- $date := .Get "date" -}}
{{- $id := delimit (split (md5 $date) "" | shuffle) "" | printf "countdown-%s" -}}
{{- $defaultPattern := printf "%%D %s %%H %s %%M %s %%S %s" (T "day") (T "hour") (T "minute") (T "second") -}}
{{- $new := dict $id (dict "date" $date "pattern" (.Get "pattern" | default $defaultPattern)) -}}
{{- with .Page.Scratch.Get "countdownMap" -}}
{{- .Page.Scratch.Set "countdownMap" (merge . $new) -}}
{{- else -}}
{{- .Page.Scratch.Set "countdownMap" $new -}}
{{- end -}}
<div id="{{ $id }}" style={{ .Get "style" | safeCSS }}></div>
{{- end -}}