mirror of
https://github.com/dillonzq/LoveIt.git
synced 2025-03-13 11:18:15 +01:00
chore(build): update build system (#920)
This commit is contained in:
parent
860fc24d8f
commit
c51e292f94
6 changed files with 5379 additions and 6625 deletions
|
@ -1,48 +1,32 @@
|
|||
"use strict";
|
||||
|
||||
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure undefined"); }
|
||||
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
|
||||
function _objectDestructuringEmpty(t) { if (null == t) throw new TypeError("Cannot destructure " + t); }
|
||||
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
||||
|
||||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
||||
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
||||
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
||||
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
|
||||
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
||||
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
||||
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
||||
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
||||
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
||||
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
||||
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
var Util = /*#__PURE__*/function () {
|
||||
function Util() {
|
||||
_classCallCheck(this, Util);
|
||||
}
|
||||
|
||||
_createClass(Util, null, [{
|
||||
return _createClass(Util, null, [{
|
||||
key: "forEach",
|
||||
value: function forEach(elements, handler) {
|
||||
elements = elements || [];
|
||||
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
handler(elements[i]);
|
||||
}
|
||||
for (var i = 0; i < elements.length; i++) handler(elements[i]);
|
||||
}
|
||||
}, {
|
||||
key: "getScrollTop",
|
||||
|
@ -63,31 +47,21 @@ var Util = /*#__PURE__*/function () {
|
|||
key: "animateCSS",
|
||||
value: function animateCSS(element, animation, reserved, callback) {
|
||||
var _element$classList;
|
||||
|
||||
if (!Array.isArray(animation)) animation = [animation];
|
||||
|
||||
(_element$classList = element.classList).add.apply(_element$classList, ['animate__animated'].concat(_toConsumableArray(animation)));
|
||||
|
||||
var handler = function handler() {
|
||||
var _handler = function handler() {
|
||||
var _element$classList2;
|
||||
|
||||
(_element$classList2 = element.classList).remove.apply(_element$classList2, ['animate__animated'].concat(_toConsumableArray(animation)));
|
||||
|
||||
element.removeEventListener('animationend', handler);
|
||||
element.removeEventListener('animationend', _handler);
|
||||
if (typeof callback === 'function') callback();
|
||||
};
|
||||
|
||||
if (!reserved) element.addEventListener('animationend', handler, false);
|
||||
if (!reserved) element.addEventListener('animationend', _handler, false);
|
||||
}
|
||||
}]);
|
||||
|
||||
return Util;
|
||||
}();
|
||||
|
||||
var Theme = /*#__PURE__*/function () {
|
||||
function Theme() {
|
||||
_classCallCheck(this, Theme);
|
||||
|
||||
this.config = window.config;
|
||||
this.data = this.config.data;
|
||||
this.isDark = document.body.getAttribute('theme') === 'dark';
|
||||
|
@ -99,12 +73,10 @@ var Theme = /*#__PURE__*/function () {
|
|||
this.clickMaskEventSet = new Set();
|
||||
if (window.objectFitImages) objectFitImages();
|
||||
}
|
||||
|
||||
_createClass(Theme, [{
|
||||
return _createClass(Theme, [{
|
||||
key: "initRaw",
|
||||
value: function initRaw() {
|
||||
var _this = this;
|
||||
|
||||
Util.forEach(document.querySelectorAll('[data-raw]'), function ($raw) {
|
||||
$raw.innerHTML = _this.data[$raw.id];
|
||||
});
|
||||
|
@ -144,28 +116,23 @@ var Theme = /*#__PURE__*/function () {
|
|||
$menuToggleMobile.classList.toggle('active');
|
||||
$menuMobile.classList.toggle('active');
|
||||
}, false);
|
||||
|
||||
this._menuMobileOnClickMask = this._menuMobileOnClickMask || function () {
|
||||
$menuToggleMobile.classList.remove('active');
|
||||
$menuMobile.classList.remove('active');
|
||||
};
|
||||
|
||||
this.clickMaskEventSet.add(this._menuMobileOnClickMask);
|
||||
}
|
||||
}, {
|
||||
key: "initSwitchTheme",
|
||||
value: function initSwitchTheme() {
|
||||
var _this2 = this;
|
||||
|
||||
Util.forEach(document.getElementsByClassName('theme-switch'), function ($themeSwitch) {
|
||||
$themeSwitch.addEventListener('click', function () {
|
||||
if (document.body.getAttribute('theme') === 'dark') document.body.setAttribute('theme', 'light');else document.body.setAttribute('theme', 'dark');
|
||||
_this2.isDark = !_this2.isDark;
|
||||
window.localStorage && localStorage.setItem('theme', _this2.isDark ? 'dark' : 'light');
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(_this2.switchThemeEventSet),
|
||||
_step;
|
||||
|
||||
_step;
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
var event = _step.value;
|
||||
|
@ -183,7 +150,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
key: "initSearch",
|
||||
value: function initSearch() {
|
||||
var _this3 = this;
|
||||
|
||||
var searchConfig = this.config.search;
|
||||
var isMobile = Util.isMobile();
|
||||
if (!searchConfig || isMobile && this._searchMobileOnce || !isMobile && this._searchDesktopOnce) return;
|
||||
|
@ -196,7 +162,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
var $searchToggle = document.getElementById("search-toggle-".concat(suffix));
|
||||
var $searchLoading = document.getElementById("search-loading-".concat(suffix));
|
||||
var $searchClear = document.getElementById("search-clear-".concat(suffix));
|
||||
|
||||
if (isMobile) {
|
||||
this._searchMobileOnce = true;
|
||||
$searchInput.addEventListener('focus', function () {
|
||||
|
@ -216,14 +181,12 @@ var Theme = /*#__PURE__*/function () {
|
|||
$searchClear.style.display = 'none';
|
||||
_this3._searchMobile && _this3._searchMobile.autocomplete.setVal('');
|
||||
}, false);
|
||||
|
||||
this._searchMobileOnClickMask = this._searchMobileOnClickMask || function () {
|
||||
$header.classList.remove('open');
|
||||
$searchLoading.style.display = 'none';
|
||||
$searchClear.style.display = 'none';
|
||||
_this3._searchMobile && _this3._searchMobile.autocomplete.setVal('');
|
||||
};
|
||||
|
||||
this.clickMaskEventSet.add(this._searchMobileOnClickMask);
|
||||
} else {
|
||||
this._searchDesktopOnce = true;
|
||||
|
@ -236,21 +199,17 @@ var Theme = /*#__PURE__*/function () {
|
|||
$searchClear.style.display = 'none';
|
||||
_this3._searchDesktop && _this3._searchDesktop.autocomplete.setVal('');
|
||||
}, false);
|
||||
|
||||
this._searchDesktopOnClickMask = this._searchDesktopOnClickMask || function () {
|
||||
$header.classList.remove('open');
|
||||
$searchLoading.style.display = 'none';
|
||||
$searchClear.style.display = 'none';
|
||||
_this3._searchDesktop && _this3._searchDesktop.autocomplete.setVal('');
|
||||
};
|
||||
|
||||
this.clickMaskEventSet.add(this._searchDesktopOnClickMask);
|
||||
}
|
||||
|
||||
$searchInput.addEventListener('input', function () {
|
||||
if ($searchInput.value === '') $searchClear.style.display = 'none';else $searchClear.style.display = 'inline';
|
||||
}, false);
|
||||
|
||||
var initAutosearch = function initAutosearch() {
|
||||
var autosearch = autocomplete("#search-input-".concat(suffix), {
|
||||
hint: false,
|
||||
|
@ -266,44 +225,38 @@ var Theme = /*#__PURE__*/function () {
|
|||
source: function source(query, callback) {
|
||||
$searchLoading.style.display = 'inline';
|
||||
$searchClear.style.display = 'none';
|
||||
|
||||
var finish = function finish(results) {
|
||||
$searchLoading.style.display = 'none';
|
||||
$searchClear.style.display = 'inline';
|
||||
callback(results);
|
||||
};
|
||||
|
||||
if (searchConfig.type === 'lunr') {
|
||||
var search = function search() {
|
||||
if (lunr.queryHandler) query = lunr.queryHandler(query);
|
||||
var results = {};
|
||||
|
||||
_this3._index.search(query).forEach(function (_ref) {
|
||||
var ref = _ref.ref,
|
||||
metadata = _ref.matchData.metadata;
|
||||
metadata = _ref.matchData.metadata;
|
||||
var matchData = _this3._indexData[ref];
|
||||
var uri = matchData.uri,
|
||||
title = matchData.title,
|
||||
context = matchData.content;
|
||||
title = matchData.title,
|
||||
context = matchData.content;
|
||||
if (results[uri]) return;
|
||||
var position = 0;
|
||||
Object.values(metadata).forEach(function (_ref2) {
|
||||
var content = _ref2.content;
|
||||
|
||||
if (content) {
|
||||
var matchPosition = content.position[0][0];
|
||||
if (matchPosition < position || position === 0) position = matchPosition;
|
||||
}
|
||||
});
|
||||
position -= snippetLength / 5;
|
||||
|
||||
if (position > 0) {
|
||||
position += context.slice(position, position + 20).lastIndexOf(' ') + 1;
|
||||
context = '...' + context.slice(position, position + snippetLength);
|
||||
} else {
|
||||
context = context.slice(0, snippetLength);
|
||||
}
|
||||
|
||||
Object.keys(metadata).forEach(function (key) {
|
||||
title = title.replace(new RegExp("(".concat(key, ")"), 'gi'), "<".concat(highlightTag, ">$1</").concat(highlightTag, ">"));
|
||||
context = context.replace(new RegExp("(".concat(key, ")"), 'gi'), "<".concat(highlightTag, ">$1</").concat(highlightTag, ">"));
|
||||
|
@ -315,10 +268,8 @@ var Theme = /*#__PURE__*/function () {
|
|||
'context': context
|
||||
};
|
||||
});
|
||||
|
||||
return Object.values(results).slice(0, maxResultLength);
|
||||
};
|
||||
|
||||
if (!_this3._index) {
|
||||
fetch(searchConfig.lunrIndexURL).then(function (response) {
|
||||
return response.json();
|
||||
|
@ -326,7 +277,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
var indexData = {};
|
||||
_this3._index = lunr(function () {
|
||||
var _this4 = this;
|
||||
|
||||
if (searchConfig.lunrLanguageCode) this.use(lunr[searchConfig.lunrLanguageCode]);
|
||||
this.ref('objectID');
|
||||
this.field('title', {
|
||||
|
@ -344,7 +294,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
this.metadataWhitelist = ['position'];
|
||||
data.forEach(function (record) {
|
||||
indexData[record.objectID] = record;
|
||||
|
||||
_this4.add(record);
|
||||
});
|
||||
});
|
||||
|
@ -358,7 +307,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
} else if (searchConfig.type === 'algolia') {
|
||||
var algoliasearch = window['algoliasearch/lite'].liteClient;
|
||||
_this3._algoliaIndex = _this3._algoliaIndex || algoliasearch(searchConfig.algoliaAppID, searchConfig.algoliaSearchKey);
|
||||
|
||||
_this3._algoliaIndex.search({
|
||||
requests: [{
|
||||
indexName: searchConfig.algoliaIndex,
|
||||
|
@ -372,14 +320,13 @@ var Theme = /*#__PURE__*/function () {
|
|||
}]
|
||||
}).then(function (_ref3) {
|
||||
var _ref3$results = _slicedToArray(_ref3.results, 1),
|
||||
hits = _ref3$results[0].hits;
|
||||
|
||||
hits = _ref3$results[0].hits;
|
||||
var results = {};
|
||||
hits.forEach(function (_ref4) {
|
||||
var uri = _ref4.uri,
|
||||
date = _ref4.date,
|
||||
title = _ref4._highlightResult.title,
|
||||
content = _ref4._snippetResult.content;
|
||||
date = _ref4.date,
|
||||
title = _ref4._highlightResult.title,
|
||||
content = _ref4._snippetResult.content;
|
||||
if (results[uri] && results[uri].context.length > content.value) return;
|
||||
results[uri] = {
|
||||
uri: uri,
|
||||
|
@ -398,8 +345,8 @@ var Theme = /*#__PURE__*/function () {
|
|||
templates: {
|
||||
suggestion: function suggestion(_ref5) {
|
||||
var title = _ref5.title,
|
||||
date = _ref5.date,
|
||||
context = _ref5.context;
|
||||
date = _ref5.date,
|
||||
context = _ref5.context;
|
||||
return "<div><span class=\"suggestion-title\">".concat(title, "</span><span class=\"suggestion-date\">").concat(date, "</span></div><div class=\"suggestion-context\">").concat(context, "</div>");
|
||||
},
|
||||
empty: function empty(_ref6) {
|
||||
|
@ -408,20 +355,18 @@ var Theme = /*#__PURE__*/function () {
|
|||
},
|
||||
footer: function footer(_ref7) {
|
||||
_objectDestructuringEmpty(_ref7);
|
||||
|
||||
var _ref8 = searchConfig.type === 'algolia' ? {
|
||||
searchType: 'algolia',
|
||||
icon: '<i class="fab fa-algolia fa-fw" aria-hidden="true"></i>',
|
||||
href: 'https://www.algolia.com/'
|
||||
} : {
|
||||
searchType: 'Lunr.js',
|
||||
icon: '',
|
||||
href: 'https://lunrjs.com/'
|
||||
},
|
||||
searchType = _ref8.searchType,
|
||||
icon = _ref8.icon,
|
||||
href = _ref8.href;
|
||||
|
||||
searchType: 'algolia',
|
||||
icon: '<i class="fab fa-algolia fa-fw" aria-hidden="true"></i>',
|
||||
href: 'https://www.algolia.com/'
|
||||
} : {
|
||||
searchType: 'Lunr.js',
|
||||
icon: '',
|
||||
href: 'https://lunrjs.com/'
|
||||
},
|
||||
searchType = _ref8.searchType,
|
||||
icon = _ref8.icon,
|
||||
href = _ref8.href;
|
||||
return "<div class=\"search-footer\">Search by <a href=\"".concat(href, "\" rel=\"noopener noreffer\" target=\"_blank\">").concat(icon, " ").concat(searchType, "</a></div>");
|
||||
}
|
||||
}
|
||||
|
@ -431,14 +376,12 @@ var Theme = /*#__PURE__*/function () {
|
|||
});
|
||||
if (isMobile) _this3._searchMobile = autosearch;else _this3._searchDesktop = autosearch;
|
||||
};
|
||||
|
||||
if (searchConfig.lunrSegmentitURL && !document.getElementById('lunr-segmentit')) {
|
||||
var script = document.createElement('script');
|
||||
script.id = 'lunr-segmentit';
|
||||
script.type = 'text/javascript';
|
||||
script.src = searchConfig.lunrSegmentitURL;
|
||||
script.async = true;
|
||||
|
||||
if (script.readyState) {
|
||||
script.onreadystatechange = function () {
|
||||
if (script.readyState === 'loaded' || script.readyState === 'complete') {
|
||||
|
@ -451,7 +394,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
initAutosearch();
|
||||
};
|
||||
}
|
||||
|
||||
document.body.appendChild(script);
|
||||
} else initAutosearch();
|
||||
}
|
||||
|
@ -487,23 +429,18 @@ var Theme = /*#__PURE__*/function () {
|
|||
value: function initHighlight() {
|
||||
Util.forEach(document.querySelectorAll('.code-block'), function ($codeBlock) {
|
||||
var $codeTitle = $codeBlock.querySelector('.code-header > .code-title');
|
||||
|
||||
if ($codeTitle) {
|
||||
$codeTitle.addEventListener('click', function () {
|
||||
$codeBlock.classList.toggle('open');
|
||||
}, false);
|
||||
}
|
||||
|
||||
var $ellipses = $codeBlock.querySelector('.code-header .ellipses');
|
||||
|
||||
if ($ellipses) {
|
||||
$ellipses.addEventListener('click', function () {
|
||||
$codeBlock.classList.toggle('open');
|
||||
}, false);
|
||||
}
|
||||
|
||||
var $copy = $codeBlock.querySelector('.code-header .copy');
|
||||
|
||||
if ($copy) {
|
||||
var $code = $codeBlock.querySelector('code');
|
||||
$copy.setAttribute('data-clipboard-text', $code.innerText);
|
||||
|
@ -533,27 +470,21 @@ var Theme = /*#__PURE__*/function () {
|
|||
key: "initToc",
|
||||
value: function initToc() {
|
||||
var _this5 = this;
|
||||
|
||||
var $tocCore = document.getElementById('TableOfContents');
|
||||
if ($tocCore === null) return;
|
||||
|
||||
if (document.getElementById('toc-static').getAttribute('data-kept') || Util.isTocStatic()) {
|
||||
var $tocContentStatic = document.getElementById('toc-content-static');
|
||||
|
||||
if ($tocCore.parentElement !== $tocContentStatic) {
|
||||
$tocCore.parentElement.removeChild($tocCore);
|
||||
$tocContentStatic.appendChild($tocCore);
|
||||
}
|
||||
|
||||
if (this._tocOnScroll) this.scrollEventSet.delete(this._tocOnScroll);
|
||||
} else {
|
||||
var $tocContentAuto = document.getElementById('toc-content-auto');
|
||||
|
||||
if ($tocCore.parentElement !== $tocContentAuto) {
|
||||
$tocCore.parentElement.removeChild($tocCore);
|
||||
$tocContentAuto.appendChild($tocCore);
|
||||
}
|
||||
|
||||
var $toc = document.getElementById('toc-auto');
|
||||
var $page = document.getElementsByClassName('page')[0];
|
||||
var rect = $page.getBoundingClientRect();
|
||||
|
@ -568,12 +499,10 @@ var Theme = /*#__PURE__*/function () {
|
|||
var TOP_SPACING = 20 + (headerIsFixed ? headerHeight : 0);
|
||||
var minTocTop = $toc.offsetTop;
|
||||
var minScrollTop = minTocTop - TOP_SPACING + (headerIsFixed ? 0 : headerHeight);
|
||||
|
||||
this._tocOnScroll = this._tocOnScroll || function () {
|
||||
var footerTop = document.getElementById('post-footer').offsetTop;
|
||||
var maxTocTop = footerTop - $toc.getBoundingClientRect().height;
|
||||
var maxScrollTop = maxTocTop - TOP_SPACING + (headerIsFixed ? 0 : headerHeight);
|
||||
|
||||
if (_this5.newScrollTop < minScrollTop) {
|
||||
$toc.style.position = 'absolute';
|
||||
$toc.style.top = "".concat(minTocTop, "px");
|
||||
|
@ -584,7 +513,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
$toc.style.position = 'fixed';
|
||||
$toc.style.top = "".concat(TOP_SPACING, "px");
|
||||
}
|
||||
|
||||
Util.forEach($tocLinkElements, function ($tocLink) {
|
||||
$tocLink.classList.remove('active');
|
||||
});
|
||||
|
@ -593,30 +521,24 @@ var Theme = /*#__PURE__*/function () {
|
|||
});
|
||||
var INDEX_SPACING = 20 + (headerIsFixed ? headerHeight : 0);
|
||||
var activeTocIndex = $headerLinkElements.length - 1;
|
||||
|
||||
for (var i = 0; i < $headerLinkElements.length - 1; i++) {
|
||||
var thisTop = $headerLinkElements[i].getBoundingClientRect().top;
|
||||
var nextTop = $headerLinkElements[i + 1].getBoundingClientRect().top;
|
||||
|
||||
if (i === 0 && thisTop > INDEX_SPACING || thisTop <= INDEX_SPACING && nextTop > INDEX_SPACING) {
|
||||
activeTocIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (activeTocIndex !== -1) {
|
||||
$tocLinkElements[activeTocIndex].classList.add('active');
|
||||
var $parent = $tocLinkElements[activeTocIndex].parentElement;
|
||||
|
||||
while ($parent !== $tocCore) {
|
||||
$parent.classList.add('has-active');
|
||||
$parent = $parent.parentElement.parentElement;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this._tocOnScroll();
|
||||
|
||||
this.scrollEventSet.add(this._tocOnScroll);
|
||||
}
|
||||
}
|
||||
|
@ -629,10 +551,8 @@ var Theme = /*#__PURE__*/function () {
|
|||
key: "initMermaid",
|
||||
value: function initMermaid() {
|
||||
var _this6 = this;
|
||||
|
||||
this._mermaidOnSwitchTheme = this._mermaidOnSwitchTheme || function () {
|
||||
var $mermaidElements = document.getElementsByClassName('mermaid');
|
||||
|
||||
if ($mermaidElements.length) {
|
||||
mermaid.initialize({
|
||||
startOnLoad: false,
|
||||
|
@ -646,48 +566,37 @@ var Theme = /*#__PURE__*/function () {
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.switchThemeEventSet.add(this._mermaidOnSwitchTheme);
|
||||
|
||||
this._mermaidOnSwitchTheme();
|
||||
}
|
||||
}, {
|
||||
key: "initEcharts",
|
||||
value: function initEcharts() {
|
||||
var _this7 = this;
|
||||
|
||||
if (this.config.echarts) {
|
||||
echarts.registerTheme('light', this.config.echarts.lightTheme);
|
||||
echarts.registerTheme('dark', this.config.echarts.darkTheme);
|
||||
|
||||
this._echartsOnSwitchTheme = this._echartsOnSwitchTheme || function () {
|
||||
_this7._echartsArr = _this7._echartsArr || [];
|
||||
|
||||
for (var i = 0; i < _this7._echartsArr.length; i++) {
|
||||
_this7._echartsArr[i].dispose();
|
||||
}
|
||||
|
||||
_this7._echartsArr = [];
|
||||
Util.forEach(document.getElementsByClassName('echarts'), function ($echarts) {
|
||||
var chart = echarts.init($echarts, _this7.isDark ? 'dark' : 'light', {
|
||||
renderer: 'svg'
|
||||
});
|
||||
chart.setOption(JSON.parse(_this7.data[$echarts.id]));
|
||||
|
||||
_this7._echartsArr.push(chart);
|
||||
});
|
||||
};
|
||||
|
||||
this.switchThemeEventSet.add(this._echartsOnSwitchTheme);
|
||||
|
||||
this._echartsOnSwitchTheme();
|
||||
|
||||
this._echartsOnResize = this._echartsOnResize || function () {
|
||||
for (var i = 0; i < _this7._echartsArr.length; i++) {
|
||||
_this7._echartsArr[i].resize();
|
||||
}
|
||||
};
|
||||
|
||||
this.resizeEventSet.add(this._echartsOnResize);
|
||||
}
|
||||
}
|
||||
|
@ -695,23 +604,22 @@ var Theme = /*#__PURE__*/function () {
|
|||
key: "initMapbox",
|
||||
value: function initMapbox() {
|
||||
var _this8 = this;
|
||||
|
||||
if (this.config.mapbox) {
|
||||
mapboxgl.accessToken = this.config.mapbox.accessToken;
|
||||
mapboxgl.setRTLTextPlugin(this.config.mapbox.RTLTextPlugin);
|
||||
this._mapboxArr = this._mapboxArr || [];
|
||||
Util.forEach(document.getElementsByClassName('mapbox'), function ($mapbox) {
|
||||
var _this8$data$$mapbox$i = _this8.data[$mapbox.id],
|
||||
lng = _this8$data$$mapbox$i.lng,
|
||||
lat = _this8$data$$mapbox$i.lat,
|
||||
zoom = _this8$data$$mapbox$i.zoom,
|
||||
lightStyle = _this8$data$$mapbox$i.lightStyle,
|
||||
darkStyle = _this8$data$$mapbox$i.darkStyle,
|
||||
marked = _this8$data$$mapbox$i.marked,
|
||||
navigation = _this8$data$$mapbox$i.navigation,
|
||||
geolocate = _this8$data$$mapbox$i.geolocate,
|
||||
scale = _this8$data$$mapbox$i.scale,
|
||||
fullscreen = _this8$data$$mapbox$i.fullscreen;
|
||||
lng = _this8$data$$mapbox$i.lng,
|
||||
lat = _this8$data$$mapbox$i.lat,
|
||||
zoom = _this8$data$$mapbox$i.zoom,
|
||||
lightStyle = _this8$data$$mapbox$i.lightStyle,
|
||||
darkStyle = _this8$data$$mapbox$i.darkStyle,
|
||||
marked = _this8$data$$mapbox$i.marked,
|
||||
navigation = _this8$data$$mapbox$i.navigation,
|
||||
geolocate = _this8$data$$mapbox$i.geolocate,
|
||||
scale = _this8$data$$mapbox$i.scale,
|
||||
fullscreen = _this8$data$$mapbox$i.fullscreen;
|
||||
var mapbox = new mapboxgl.Map({
|
||||
container: $mapbox,
|
||||
center: [lng, lat],
|
||||
|
@ -720,15 +628,12 @@ var Theme = /*#__PURE__*/function () {
|
|||
style: _this8.isDark ? darkStyle : lightStyle,
|
||||
attributionControl: false
|
||||
});
|
||||
|
||||
if (marked) {
|
||||
new mapboxgl.Marker().setLngLat([lng, lat]).addTo(mapbox);
|
||||
}
|
||||
|
||||
if (navigation) {
|
||||
mapbox.addControl(new mapboxgl.NavigationControl(), 'bottom-right');
|
||||
}
|
||||
|
||||
if (geolocate) {
|
||||
mapbox.addControl(new mapboxgl.GeolocateControl({
|
||||
positionOptions: {
|
||||
|
@ -738,31 +643,25 @@ var Theme = /*#__PURE__*/function () {
|
|||
trackUserLocation: true
|
||||
}), 'bottom-right');
|
||||
}
|
||||
|
||||
if (scale) {
|
||||
mapbox.addControl(new mapboxgl.ScaleControl());
|
||||
}
|
||||
|
||||
if (fullscreen) {
|
||||
mapbox.addControl(new mapboxgl.FullscreenControl());
|
||||
}
|
||||
|
||||
mapbox.addControl(new MapboxLanguage());
|
||||
|
||||
_this8._mapboxArr.push(mapbox);
|
||||
});
|
||||
|
||||
this._mapboxOnSwitchTheme = this._mapboxOnSwitchTheme || function () {
|
||||
Util.forEach(_this8._mapboxArr, function (mapbox) {
|
||||
var $mapbox = mapbox.getContainer();
|
||||
var _this8$data$$mapbox$i2 = _this8.data[$mapbox.id],
|
||||
lightStyle = _this8$data$$mapbox$i2.lightStyle,
|
||||
darkStyle = _this8$data$$mapbox$i2.darkStyle;
|
||||
lightStyle = _this8$data$$mapbox$i2.lightStyle,
|
||||
darkStyle = _this8$data$$mapbox$i2.darkStyle;
|
||||
mapbox.setStyle(_this8.isDark ? darkStyle : lightStyle);
|
||||
mapbox.addControl(new MapboxLanguage());
|
||||
});
|
||||
};
|
||||
|
||||
this.switchThemeEventSet.add(this._mapboxOnSwitchTheme);
|
||||
}
|
||||
}
|
||||
|
@ -770,14 +669,13 @@ var Theme = /*#__PURE__*/function () {
|
|||
key: "initTypeit",
|
||||
value: function initTypeit() {
|
||||
var _this9 = this;
|
||||
|
||||
if (this.config.typeit) {
|
||||
var typeitConfig = this.config.typeit;
|
||||
var speed = typeitConfig.speed ? typeitConfig.speed : 100;
|
||||
var cursorSpeed = typeitConfig.cursorSpeed ? typeitConfig.cursorSpeed : 1000;
|
||||
var cursorChar = typeitConfig.cursorChar ? typeitConfig.cursorChar : '|';
|
||||
Object.values(typeitConfig.data).forEach(function (group) {
|
||||
var typeone = function typeone(i) {
|
||||
var _typeone = function typeone(i) {
|
||||
var id = group[i];
|
||||
new TypeIt("#".concat(id), {
|
||||
strings: _this9.data[id],
|
||||
|
@ -793,14 +691,12 @@ var Theme = /*#__PURE__*/function () {
|
|||
}, typeitConfig.duration);
|
||||
return;
|
||||
}
|
||||
|
||||
instance.destroy();
|
||||
typeone(i + 1);
|
||||
_typeone(i + 1);
|
||||
}
|
||||
}).go();
|
||||
};
|
||||
|
||||
typeone(0);
|
||||
_typeone(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -808,16 +704,13 @@ var Theme = /*#__PURE__*/function () {
|
|||
key: "initComment",
|
||||
value: function initComment() {
|
||||
var _this10 = this;
|
||||
|
||||
if (this.config.comment) {
|
||||
if (this.config.comment.gitalk) {
|
||||
this.config.comment.gitalk.body = decodeURI(window.location.href);
|
||||
var gitalk = new Gitalk(this.config.comment.gitalk);
|
||||
gitalk.render('gitalk');
|
||||
}
|
||||
|
||||
if (this.config.comment.valine) new Valine(this.config.comment.valine);
|
||||
|
||||
if (this.config.comment.utterances) {
|
||||
var utterancesConfig = this.config.comment.utterances;
|
||||
var script = document.createElement('script');
|
||||
|
@ -830,7 +723,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
script.crossOrigin = 'anonymous';
|
||||
script.async = true;
|
||||
document.getElementById('utterances').appendChild(script);
|
||||
|
||||
this._utterancesOnSwitchTheme = this._utterancesOnSwitchTheme || function () {
|
||||
var message = {
|
||||
type: 'set-theme',
|
||||
|
@ -839,10 +731,8 @@ var Theme = /*#__PURE__*/function () {
|
|||
var iframe = document.querySelector('.utterances-frame');
|
||||
iframe.contentWindow.postMessage(message, 'https://utteranc.es');
|
||||
};
|
||||
|
||||
this.switchThemeEventSet.add(this._utterancesOnSwitchTheme);
|
||||
}
|
||||
|
||||
if (this.config.comment.giscus) {
|
||||
var giscusConfig = this.config.comment.giscus;
|
||||
var giscusScript = document.createElement('script');
|
||||
|
@ -862,7 +752,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
giscusScript.crossOrigin = 'anonymous';
|
||||
giscusScript.async = true;
|
||||
document.getElementById('giscus').appendChild(giscusScript);
|
||||
|
||||
this._giscusOnSwitchTheme = this._giscusOnSwitchTheme || function () {
|
||||
var message = {
|
||||
setConfig: {
|
||||
|
@ -876,7 +765,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
giscus: message
|
||||
}, 'https://giscus.app');
|
||||
};
|
||||
|
||||
this.switchThemeEventSet.add(this._giscusOnSwitchTheme);
|
||||
}
|
||||
}
|
||||
|
@ -890,21 +778,18 @@ var Theme = /*#__PURE__*/function () {
|
|||
key: "onScroll",
|
||||
value: function onScroll() {
|
||||
var _this11 = this;
|
||||
|
||||
var $headers = [];
|
||||
if (document.body.getAttribute('data-header-desktop') === 'auto') $headers.push(document.getElementById('header-desktop'));
|
||||
if (document.body.getAttribute('data-header-mobile') === 'auto') $headers.push(document.getElementById('header-mobile'));
|
||||
|
||||
if (document.getElementById('comments')) {
|
||||
var $viewComments = document.getElementById('view-comments');
|
||||
$viewComments.href = "#comments";
|
||||
$viewComments.parentElement.removeChild($viewComments);
|
||||
document.getElementById('fixed-buttons').appendChild($viewComments);
|
||||
}
|
||||
|
||||
var $fixedButtons = document.getElementById('fixed-buttons');
|
||||
var ACCURACY = 20,
|
||||
MINIMUM = 100;
|
||||
MINIMUM = 100;
|
||||
window.addEventListener('scroll', function () {
|
||||
_this11.newScrollTop = Util.getScrollTop();
|
||||
var scroll = _this11.newScrollTop - _this11.oldScrollTop;
|
||||
|
@ -918,7 +803,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
Util.animateCSS($header, ['animate__fadeInDown', 'animate__faster'], true);
|
||||
}
|
||||
});
|
||||
|
||||
if (_this11.newScrollTop > MINIMUM) {
|
||||
if (isMobile && scroll > ACCURACY) {
|
||||
$fixedButtons.classList.remove('animate__fadeIn');
|
||||
|
@ -933,13 +817,10 @@ var Theme = /*#__PURE__*/function () {
|
|||
$fixedButtons.classList.remove('animate__fadeIn');
|
||||
Util.animateCSS($fixedButtons, ['animate__fadeOut', 'animate__faster'], true);
|
||||
}
|
||||
|
||||
$fixedButtons.style.display = 'none';
|
||||
}
|
||||
|
||||
var _iterator2 = _createForOfIteratorHelper(_this11.scrollEventSet),
|
||||
_step2;
|
||||
|
||||
_step2;
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
var event = _step2.value;
|
||||
|
@ -950,7 +831,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
|
||||
_this11.oldScrollTop = _this11.newScrollTop;
|
||||
}, false);
|
||||
}
|
||||
|
@ -958,15 +838,12 @@ var Theme = /*#__PURE__*/function () {
|
|||
key: "onResize",
|
||||
value: function onResize() {
|
||||
var _this12 = this;
|
||||
|
||||
window.addEventListener('resize', function () {
|
||||
if (!_this12._resizeTimeout) {
|
||||
_this12._resizeTimeout = window.setTimeout(function () {
|
||||
_this12._resizeTimeout = null;
|
||||
|
||||
var _iterator3 = _createForOfIteratorHelper(_this12.resizeEventSet),
|
||||
_step3;
|
||||
|
||||
_step3;
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
var event = _step3.value;
|
||||
|
@ -977,11 +854,8 @@ var Theme = /*#__PURE__*/function () {
|
|||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
|
||||
_this12.initToc();
|
||||
|
||||
_this12.initMermaid();
|
||||
|
||||
_this12.initSearch();
|
||||
}, 100);
|
||||
}
|
||||
|
@ -991,11 +865,9 @@ var Theme = /*#__PURE__*/function () {
|
|||
key: "onClickMask",
|
||||
value: function onClickMask() {
|
||||
var _this13 = this;
|
||||
|
||||
document.getElementById('mask').addEventListener('click', function () {
|
||||
var _iterator4 = _createForOfIteratorHelper(_this13.clickMaskEventSet),
|
||||
_step4;
|
||||
|
||||
_step4;
|
||||
try {
|
||||
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
||||
var event = _step4.value;
|
||||
|
@ -1006,7 +878,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
} finally {
|
||||
_iterator4.f();
|
||||
}
|
||||
|
||||
document.body.classList.remove('blur');
|
||||
}, false);
|
||||
}
|
||||
|
@ -1014,7 +885,6 @@ var Theme = /*#__PURE__*/function () {
|
|||
key: "init",
|
||||
value: function init() {
|
||||
var _this14 = this;
|
||||
|
||||
try {
|
||||
this.initRaw();
|
||||
this.initSVGIcon();
|
||||
|
@ -1035,29 +905,20 @@ var Theme = /*#__PURE__*/function () {
|
|||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
window.setTimeout(function () {
|
||||
_this14.initToc();
|
||||
|
||||
_this14.initComment();
|
||||
|
||||
_this14.onScroll();
|
||||
|
||||
_this14.onResize();
|
||||
|
||||
_this14.onClickMask();
|
||||
}, 100);
|
||||
}
|
||||
}]);
|
||||
|
||||
return Theme;
|
||||
}();
|
||||
|
||||
var themeInit = function themeInit() {
|
||||
var theme = new Theme();
|
||||
theme.init();
|
||||
};
|
||||
|
||||
if (document.readyState !== 'loading') {
|
||||
themeInit();
|
||||
} else {
|
||||
|
|
|
@ -172,10 +172,8 @@ n.CHS_NAMES=T,n.ChsNameOptimizer=Z,n.ChsNameTokenizer=k,n.DatetimeOptimizer=$,n.
|
|||
"use strict";
|
||||
|
||||
var _segmentit = require("segmentit");
|
||||
|
||||
var segmentit = (0, _segmentit.useDefault)(new _segmentit.Segment());
|
||||
lunr.segmentit = segmentit;
|
||||
|
||||
lunr.queryHandler = function (query) {
|
||||
if (/^[\u4e00-\u9fa5]+$/.test(query)) query = lunr.segmentit.doSegment(query).map(function (seg) {
|
||||
return '+' + seg.w;
|
||||
|
|
17
netlify.toml
17
netlify.toml
|
@ -3,16 +3,27 @@
|
|||
|
||||
[build.environment]
|
||||
HUGO_VERSION = "0.144.2"
|
||||
HUGO_ENV = "production"
|
||||
HUGO_ENABLEGITINFO = "true"
|
||||
|
||||
[context.production]
|
||||
command = "hugo --source exampleSite --theme repo --themesDir ../.. --baseURL ${URL} --gc --minify"
|
||||
|
||||
[context.production.environment]
|
||||
HUGO_ENV = "production"
|
||||
|
||||
[context.deploy-preview]
|
||||
command = "hugo --source exampleSite --theme repo --themesDir ../.. --baseURL ${DEPLOY_PRIME_URL} --gc --minify --buildDrafts"
|
||||
|
||||
[context.branch-deploy]
|
||||
command = "hugo --source exampleSite --theme repo --themesDir ../.. --baseURL ${DEPLOY_PRIME_URL} --gc --minify"
|
||||
|
||||
[[plugins]]
|
||||
package = "netlify-plugin-hugo-cache-resources"
|
||||
|
||||
[plugins.inputs]
|
||||
debug = true
|
||||
srcdir = "exampleSite"
|
||||
|
||||
[[plugins]]
|
||||
package = "@netlify/plugin-lighthouse"
|
||||
|
||||
[plugins.inputs.settings]
|
||||
preset = "desktop"
|
||||
|
|
11707
package-lock.json
generated
11707
package-lock.json
generated
File diff suppressed because it is too large
Load diff
13
package.json
13
package.json
|
@ -4,14 +4,13 @@
|
|||
"description": "LoveIt theme source file",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@algolia/cli": "^4.0.8",
|
||||
"@babel/cli": "^7.17.10",
|
||||
"@babel/core": "^7.17.10",
|
||||
"@babel/preset-env": "^7.17.10",
|
||||
"@babel/cli": "^7.26.4",
|
||||
"@babel/core": "^7.26.9",
|
||||
"@babel/preset-env": "^7.26.9",
|
||||
"babelify": "^10.0.0",
|
||||
"browserify": "^16.5.2",
|
||||
"core-js": "^3.22.4",
|
||||
"husky": "^7.0.0",
|
||||
"browserify": "^17.0.1",
|
||||
"core-js": "^3.40.0",
|
||||
"husky": "^9.1.7",
|
||||
"segmentit": "^2.0.3"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue