mirror of
https://github.com/dillonzq/LoveIt.git
synced 2024-11-12 18:06:17 +01:00
chore(hook): add babel pre-commit hook
This commit is contained in:
parent
34cc26b94a
commit
d87af71176
14 changed files with 3967 additions and 18 deletions
11
.babelrc
Normal file
11
.babelrc
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"targets": "> 0.25%, not dead"
|
||||
}
|
||||
],
|
||||
"minify"
|
||||
]
|
||||
}
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,7 +1,8 @@
|
|||
# Hugo default output directory
|
||||
public
|
||||
/exampleSite/resources
|
||||
/exampleSite/zh/resources
|
||||
public/
|
||||
/exampleSite/resources/
|
||||
/exampleSite/zh/resources/
|
||||
node_modules/
|
||||
|
||||
## OS Files
|
||||
# Windows
|
||||
|
|
|
@ -151,9 +151,6 @@
|
|||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Theme script */ -}}
|
||||
{{- slice "js/theme.js" | .Scratch.Add "scriptLocal" -}}
|
||||
|
||||
{{- range .Scratch.Get "linkCDN" -}}
|
||||
{{- safeHTML . -}}
|
||||
{{- end -}}
|
||||
|
@ -178,3 +175,6 @@
|
|||
{{- end -}}
|
||||
<script src="{{ $res.RelPermalink }}"></script>
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Theme script */ -}}
|
||||
<script src=/js/theme.min.js></script>
|
||||
|
|
3905
package-lock.json
generated
Normal file
3905
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
39
package.json
Normal file
39
package.json
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"name": "loveit-src",
|
||||
"version": "1.0.0",
|
||||
"description": "LoveIt theme source file",
|
||||
"main": "index.js",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.8.4",
|
||||
"@babel/core": "^7.8.4",
|
||||
"@babel/preset-env": "^7.8.4",
|
||||
"babel-preset-minify": "^0.5.1",
|
||||
"husky": "^4.2.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npx babel src --out-file static/js/theme.min.js --source-maps",
|
||||
"start": "hugo server --source=exampleSite --themesDir=../.. --disableFastRender -D",
|
||||
"copy": "HUGO_ENV=production hugo -v --source=exampleSite --themesDir=../.. -D --gc --minify && rm -rf resources && cp -rf exampleSite/resources resources"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run build && npm run copy",
|
||||
"pre-push": "npm run build && npm run copy"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/dillonzq/LoveIt.git"
|
||||
},
|
||||
"keywords": [
|
||||
"hugo",
|
||||
"theme"
|
||||
],
|
||||
"author": "Dillon",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/dillonzq/LoveIt/issues"
|
||||
},
|
||||
"homepage": "https://github.com/dillonzq/LoveIt#readme"
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
.dark-theme .aplayer{background:#212121}.dark-theme .aplayer.aplayer-withlist .aplayer-info{border-bottom-color:#5c5c5c}.dark-theme .aplayer.aplayer-fixed .aplayer-list{border-color:#5c5c5c}.dark-theme .aplayer .aplayer-body{background-color:#212121}.dark-theme .aplayer .aplayer-info{border-top-color:#212121}.dark-theme .aplayer .aplayer-info .aplayer-music .aplayer-title{color:#fff}.dark-theme .aplayer .aplayer-info .aplayer-music .aplayer-author{color:#fff}.dark-theme .aplayer .aplayer-info .aplayer-controller .aplayer-time{color:#eee}.dark-theme .aplayer .aplayer-info .aplayer-controller .aplayer-time .aplayer-icon path{fill:#eee}.dark-theme .aplayer .aplayer-list{background-color:#212121}.dark-theme .aplayer .aplayer-list::-webkit-scrollbar-thumb{background-color:#999}.dark-theme .aplayer .aplayer-list::-webkit-scrollbar-thumb:hover{background-color:#bbb}.dark-theme .aplayer .aplayer-list li{color:#fff;border-top-color:#666}.dark-theme .aplayer .aplayer-list li:hover{background:#4e4e4e}.dark-theme .aplayer .aplayer-list li.aplayer-list-light{background:#6c6c6c}.dark-theme .aplayer .aplayer-list li .aplayer-list-index{color:#ddd}.dark-theme .aplayer .aplayer-list li .aplayer-list-author{color:#ddd}.dark-theme .aplayer .aplayer-lrc{text-shadow:-1px -1px 0 #666}.dark-theme .aplayer .aplayer-lrc:before{background:-moz-linear-gradient(top, #212121 0%, rgba(33,33,33,0) 100%);background:-webkit-linear-gradient(top, #212121 0%, rgba(33,33,33,0) 100%);background:linear-gradient(to bottom, #212121 0%, rgba(33,33,33,0) 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#212121', endColorstr='#00212121',GradientType=0 )}.dark-theme .aplayer .aplayer-lrc:after{background:-moz-linear-gradient(top, rgba(33,33,33,0) 0%, rgba(33,33,33,0.8) 100%);background:-webkit-linear-gradient(top, rgba(33,33,33,0) 0%, rgba(33,33,33,0.8) 100%);background:linear-gradient(to bottom, rgba(33,33,33,0) 0%, rgba(33,33,33,0.8) 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#00212121', endColorstr='#cc212121',GradientType=0 )}.dark-theme .aplayer .aplayer-lrc p{color:#fff}.dark-theme .aplayer .aplayer-miniswitcher{background:#484848}.dark-theme .aplayer .aplayer-miniswitcher .aplayer-icon path{fill:#eee}
|
||||
|
||||
/*# sourceMappingURL=dark.css.map */
|
|
@ -1 +0,0 @@
|
|||
{"Target":"css/lib/aplayer/dark.css","MediaType":"text/css","Data":{}}
|
|
@ -1,3 +0,0 @@
|
|||
.dark-theme .v *,.dark-theme .v .vwrap input,.dark-theme .v .vwrap input::placeholder,.dark-theme .v .veditor,.dark-theme .v .veditor::placeholder,.dark-theme .v a,.dark-theme .v a:hover{color:rgba(255,255,255,0.75);opacity:1}.dark-theme .v .vbtn{color:rgba(255,255,255,0.75);background:#333;border:none}.dark-theme .v .vbtn:hover{color:#3090e4;border-color:#3090e4}.dark-theme .v .vlist .vcard .vhead .vsys{background:#333}.dark-theme .v code,.dark-theme .v pre{background:#272C34}.v code,.v pre{text-align:left}
|
||||
|
||||
/*# sourceMappingURL=dark.css.map */
|
|
@ -1 +0,0 @@
|
|||
{"Target":"css/lib/valine/dark.css","MediaType":"text/css","Data":{}}
|
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
{"Target":"css/mermaid.css","MediaType":"text/css","Data":{}}
|
4
static/js/theme.min.js
vendored
Normal file
4
static/js/theme.min.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
"use strict";function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}(function(){'use strict';var a=/*#__PURE__*/function(){function a(){_classCallCheck(this,a)}return _createClass(a,[{key:"forEach",value:function forEach(a,b){a=a||[];for(var c=0;c<a.length;c++)b(a[c])}},{key:"getScrollTop",value:function getScrollTop(){return document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop}}]),a}(),b=/*#__PURE__*/function(){function b(){_classCallCheck(this,b),this.util=new a,this.scrollTop=0,this.scrollEvents=[]}return _createClass(b,[{key:"initMobileMenu",value:function initMobileMenu(){document.getElementById("menu-toggle").onclick=function(){document.getElementById("menu-toggle").classList.toggle("active"),document.getElementById("menu-mobile").classList.toggle("active")}}},{key:"initSwitchTheme",value:function initSwitchTheme(){var a=this;this.util.forEach(document.getElementsByClassName("theme-switch"),function(b){b.onclick=function(){document.body.classList.toggle("dark-theme"),window.isDark=!window.isDark,window.localStorage&&window.localStorage.setItem("theme",window.isDark?"dark":"light"),a.initEcharts()}})}},{key:"initHighlight",value:function initHighlight(){this.util.forEach(document.querySelectorAll(".highlight > .chroma"),function(a){var b=a.querySelectorAll("pre.chroma > code"),c=b[b.length-1],d=c?c.className.toLowerCase():"";a.className+=" "+d}),this.util.forEach(document.querySelectorAll(".highlight > pre.chroma"),function(a){var b=document.createElement("div");b.className=a.className;var c=document.createElement("table");b.appendChild(c);var d=document.createElement("tbody");c.appendChild(d);var e=document.createElement("tr");d.appendChild(e);var f=document.createElement("td");e.appendChild(f),a.parentElement.replaceChild(b,a),f.appendChild(a)})}},{key:"initTable",value:function initTable(){this.util.forEach(document.querySelectorAll(".content table"),function(a){var b=document.createElement("div");b.className="table-wrapper",a.parentElement.replaceChild(b,a),b.appendChild(a)})}},{key:"initHeaderLink",value:function initHeaderLink(){for(var a=1;6>=a;a++)this.util.forEach(document.querySelectorAll(".content > h"+a),function(a){a.classList.add("headerLink"),a.innerHTML="<a href=\"#".concat(a.id,"\"></a>").concat(a.innerHTML)})}},{key:"_refactorToc",value:function _refactorToc(a){this.util.forEach(a.querySelectorAll("a:first-child"),function(a){a.classList.add("toc-link")});for(// when headings do not start with `h1`
|
||||
var b,c=a.children[0],d=c;1===d.children.length&&"UL"===(b=d.children[0].children[0]).tagName;)d=b;d!==c&&a.replaceChild(d,c)}},{key:"_initTocState",value:function _initTocState(a){var b=this;if("none"!==window.getComputedStyle(a,null).display){var c="normal"!==window.desktopHeaderMode,d=document.getElementById("header-desktop").getBoundingClientRect().height,e=20+(c?d:0),f=a.offsetTop,g=f-e+(c?0:d),h=document.getElementById("post-footer").offsetTop,j=a.getElementsByClassName("toc-link"),k=document.getElementsByClassName("headerLink")||[],l=a.querySelectorAll(".post-toc-content li"),m=5+(c?d:0),n=function(){var n=b.util.getScrollTop(),o=h-a.getBoundingClientRect().height,p=o-e+(c?0:d);n<g?(a.style.position="absolute",a.style.top="".concat(f,"px")):n>p?(a.style.position="absolute",a.style.top="".concat(o,"px")):(a.style.position="fixed",a.style.top="".concat(e,"px")),b.util.forEach(j,function(a){a.classList.remove("active")}),b.util.forEach(l,function(a){a.classList.remove("has-active")});for(var q=k.length-1,r=0;r<k.length-1;r++){var s=k[r].getBoundingClientRect().top,t=k[r+1].getBoundingClientRect().top;if(0==r&&s>m||s<=m&&t>m){q=r;break}}if(-1!==q){j[q].classList.add("active");for(var u=j[q].parentElement;"NAV"!==u.tagName;)u.classList.add("has-active"),u=u.parentElement.parentElement}};n(),this._initTocOnce||(this.scrollEvents.push(n),this._initTocOnce=!0)}}},{key:"initToc",value:function initToc(){var a=this,b=document.getElementById("post-toc");if(null!==b){var c=document.getElementById("TableOfContents");null===c?b.parentElement.removeChild(b):(this._refactorToc(c),this._initTocState(b),window.addEventListener("resize",function(){window.setTimeout(function(){a._initTocState(b)},0)},!1))}}},{key:"initMermaid",value:function initMermaid(){window.mermaidMap&&(mermaid.initialize({startOnLoad:!1,theme:null}),Object.keys(mermaidMap).forEach(function(a){var b=document.getElementById(a);mermaid.mermaidAPI.render("d"+a,mermaidMap[a],function(a){b.innerHTML=a;var c=b.firstChild;c.style.width="100%"},b)}))}},{key:"initEcharts",value:function initEcharts(){if(window.echartsMap){for(var a=0;a<echartsArr.length;a++)echartsArr[a].dispose();echartsArr=[],Object.keys(echartsMap).forEach(function(a){var b=echarts.init(document.getElementById(a),window.isDark?"dark":"macarons",{renderer:"svg"});b.setOption(echartsMap[a]),echartsArr.push(b)}),window.addEventListener("resize",function(){this.setTimeout(function(){for(var a=0;a<echartsArr.length;a++)echartsArr[a].resize()},0)},!1)}}},{key:"initTypeit",value:function initTypeit(){if(window.typeitArr)for(var a=function(a){var b=typeitArr[a];(function a(c){var d=document.getElementById("r".concat(b[c])).innerHTML;if(c===b.length-1)return void new TypeIt("#".concat(b[c]),{strings:d}).go();var e=new TypeIt("#".concat(b[c]),{strings:d,afterComplete:function afterComplete(){e.destroy(),a(c+1)}}).go()})(0)},b=0;b<typeitArr.length;b++)a(b)}},{key:"initScroll",value:function initScroll(){for(var a=this,b=0;b<this.scrollEvents.length;b++)document.addEventListener("scroll",this.scrollEvents[b],!1);var c=function(){var a=window.matchMedia("only screen and (max-width: 560px)").matches;!a&&"normal"===window.desktopHeaderMode||a&&"normal"===window.mobileHeaderMode?new SmoothScroll("[href^=\"#\"]",{speed:300,speedAsDuration:!0}):new SmoothScroll("[href^=\"#\"]",{speed:300,speedAsDuration:!0,header:"#header-desktop"})};c(),window.addEventListener("resize",function(){window.setTimeout(function(){c()},0)},!1);var d=[];"auto"===window.desktopHeaderMode&&d.push(document.getElementById("header-desktop")),"auto"===window.mobileHeaderMode&&d.push(document.getElementById("header-mobile")),this.util.forEach(d,function(a){a.classList.add("animated"),a.classList.add("faster")});var e=document.getElementById("dynamic-to-top");document.addEventListener("scroll",function(){var b=a.util.getScrollTop();a.util.forEach(d,function(c){a.scrollTop<b?!c.classList.contains("fadeOutUp")&&(c.classList.remove("fadeInDown"),c.classList.add("fadeOutUp")):!c.classList.contains("fadeInDown")&&(c.classList.remove("fadeOutUp"),c.classList.add("fadeInDown")),600<b?a.scrollTop<b?!e.classList.contains("fadeOut")&&(e.classList.remove("fadeIn"),e.classList.add("fadeOut")):(e.style.display="block",!e.classList.contains("fadeIn")&&(e.classList.remove("fadeOut"),e.classList.add("fadeIn"))):e.style.display="none"}),a.scrollTop=b},!1)}},{key:"init",value:function init(){this.initMobileMenu(),this.initSwitchTheme(),this.initHighlight(),this.initTable(),this.initHeaderLink(),this.initMermaid(),this.initEcharts(),this.initTypeit(),this.initToc(),this.initScroll()}}]),b}(),c=function(){var a=new b;a.init()};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",c,!1):c()})();
|
||||
|
||||
//# sourceMappingURL=theme.min.js.map
|
1
static/js/theme.min.js.map
Normal file
1
static/js/theme.min.js.map
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue