{% for item in update_list %} {% assign index = item | split: "::" | last | plus: 0 %} diff --git a/_javascript/commons/back-to-top.js b/_javascript/commons/back-to-top.js index 1807332..e876147 100644 --- a/_javascript/commons/back-to-top.js +++ b/_javascript/commons/back-to-top.js @@ -1,20 +1,20 @@ -/* -Reference: https://bootsnipp.com/snippets/featured/link-to-top-page -*/ +/** + * Reference: https://bootsnipp.com/snippets/featured/link-to-top-page + */ $(function() { - $(window).scroll(() => { - if ($(this).scrollTop() > 50 && - $("#sidebar-trigger").css("display") === "none") { - $("#back-to-top").fadeIn(); - } else { - $("#back-to-top").fadeOut(); - } - }); + $(window).scroll(() => { + if ($(this).scrollTop() > 50 && + $("#sidebar-trigger").css("display") === "none") { + $("#back-to-top").fadeIn(); + } else { + $("#back-to-top").fadeOut(); + } + }); - $("#back-to-top").click(() => { - $("body,html").animate({ - scrollTop: 0 - }, 800); - return false; - }); + $("#back-to-top").click(() => { + $("body,html").animate({ + scrollTop: 0 + }, 800); + return false; + }); }); diff --git a/_javascript/commons/mode-toggle.js b/_javascript/commons/mode-toggle.js index 1a3b3d6..6581f08 100644 --- a/_javascript/commons/mode-toggle.js +++ b/_javascript/commons/mode-toggle.js @@ -1,13 +1,13 @@ -/* +/** * Listener for theme mode toggle */ -$(function() { - $(".mode-toggle").click((e) => { - const $target = $(e.target); - let $btn = ($target.prop("tagName") === "button".toUpperCase() ? - $target : $target.parent()); +$(function () { + $(".mode-toggle").click((e) => { + const $target = $(e.target); + let $btn = ($target.prop("tagName") === "button".toUpperCase() ? + $target : $target.parent()); - $btn.blur(); // remove the clicking outline - flipMode(); - }); + $btn.blur(); // remove the clicking outline + flipMode(); + }); }); diff --git a/_javascript/commons/scroll-helper.js b/_javascript/commons/scroll-helper.js index 7892b08..419418c 100644 --- a/_javascript/commons/scroll-helper.js +++ b/_javascript/commons/scroll-helper.js @@ -2,35 +2,37 @@ * A tool for smooth scrolling and topbar switcher */ const ScrollHelper = (function () { - const $body = $("body"); - const ATTR_TOPBAR_VISIBLE = "data-topbar-visible"; - const topbarHeight = $("#topbar-wrapper").outerHeight(); + const $body = $("body"); + const ATTR_TOPBAR_VISIBLE = "data-topbar-visible"; + const topbarHeight = $("#topbar-wrapper").outerHeight(); - let scrollUpCount = 0; // the number of times the scroll up was triggered by ToC or anchor - let topbarLocked = false; - let orientationLocked = false; + let scrollUpCount = 0; // the number of times the scroll up was triggered by ToC or anchor + let topbarLocked = false; + let orientationLocked = false; - return { - hideTopbar: () => $body.attr(ATTR_TOPBAR_VISIBLE, false), - showTopbar: () => $body.attr(ATTR_TOPBAR_VISIBLE, true), + return { + hideTopbar: () => $body.attr(ATTR_TOPBAR_VISIBLE, false), + showTopbar: () => $body.attr(ATTR_TOPBAR_VISIBLE, true), - // scroll up + // scroll up - addScrollUpTask: () => { - scrollUpCount += 1; - if (!topbarLocked) { topbarLocked = true; } - }, - popScrollUpTask: () => scrollUpCount -= 1, - hasScrollUpTask: () => scrollUpCount > 0, - topbarLocked: () => topbarLocked === true, - unlockTopbar: () => topbarLocked = false, - getTopbarHeight: () => topbarHeight, + addScrollUpTask: () => { + scrollUpCount += 1; + if (!topbarLocked) { + topbarLocked = true; + } + }, + popScrollUpTask: () => scrollUpCount -= 1, + hasScrollUpTask: () => scrollUpCount > 0, + topbarLocked: () => topbarLocked === true, + unlockTopbar: () => topbarLocked = false, + getTopbarHeight: () => topbarHeight, - // orientation change + // orientation change - orientationLocked: () => orientationLocked === true, - lockOrientation: () => orientationLocked = true, - unLockOrientation: () => orientationLocked = false - }; + orientationLocked: () => orientationLocked === true, + lockOrientation: () => orientationLocked = true, + unLockOrientation: () => orientationLocked = false + }; }()); diff --git a/_javascript/commons/search-display.js b/_javascript/commons/search-display.js index 85e6b0a..ddc73c1 100644 --- a/_javascript/commons/search-display.js +++ b/_javascript/commons/search-display.js @@ -1,129 +1,129 @@ -/* -* This script make #search-result-wrapper switch to unloaded or shown automatically. -*/ +/** + * This script make #search-result-wrapper switch to unloaded or shown automatically. + */ -$(function() { - const btnSbTrigger = $("#sidebar-trigger"); - const btnSearchTrigger = $("#search-trigger"); - const btnCancel = $("#search-cancel"); - const main = $("#main"); - const topbarTitle = $("#topbar-title"); - const searchWrapper = $("#search-wrapper"); - const resultWrapper = $("#search-result-wrapper"); - const results = $("#search-results"); - const input = $("#search-input"); - const hints = $("#search-hints"); +$(function () { + const btnSbTrigger = $("#sidebar-trigger"); + const btnSearchTrigger = $("#search-trigger"); + const btnCancel = $("#search-cancel"); + const main = $("#main"); + const topbarTitle = $("#topbar-title"); + const searchWrapper = $("#search-wrapper"); + const resultWrapper = $("#search-result-wrapper"); + const results = $("#search-results"); + const input = $("#search-input"); + const hints = $("#search-hints"); - const scrollBlocker = (function () { - let offset = 0; - return { - block() { - offset = window.scrollY; - $("html,body").scrollTop(0); - }, - release() { - $("html,body").scrollTop(offset); - }, - getOffset() { - return offset; - } - }; - }()); + const scrollBlocker = (function () { + let offset = 0; + return { + block() { + offset = window.scrollY; + $("html,body").scrollTop(0); + }, + release() { + $("html,body").scrollTop(offset); + }, + getOffset() { + return offset; + } + }; + }()); - /*--- Actions in mobile screens (Sidebar hidden) ---*/ + /*--- Actions in mobile screens (Sidebar hidden) ---*/ - const mobileSearchBar = (function () { - return { - on() { - btnSbTrigger.addClass("unloaded"); - topbarTitle.addClass("unloaded"); - btnSearchTrigger.addClass("unloaded"); - searchWrapper.addClass("d-flex"); - btnCancel.addClass("loaded"); - }, - off() { - btnCancel.removeClass("loaded"); - searchWrapper.removeClass("d-flex"); - btnSbTrigger.removeClass("unloaded"); - topbarTitle.removeClass("unloaded"); - btnSearchTrigger.removeClass("unloaded"); - } - }; - }()); + const mobileSearchBar = (function () { + return { + on() { + btnSbTrigger.addClass("unloaded"); + topbarTitle.addClass("unloaded"); + btnSearchTrigger.addClass("unloaded"); + searchWrapper.addClass("d-flex"); + btnCancel.addClass("loaded"); + }, + off() { + btnCancel.removeClass("loaded"); + searchWrapper.removeClass("d-flex"); + btnSbTrigger.removeClass("unloaded"); + topbarTitle.removeClass("unloaded"); + btnSearchTrigger.removeClass("unloaded"); + } + }; + }()); - const resultSwitch = (function () { - let visible = false; + const resultSwitch = (function () { + let visible = false; - return { - on() { - if (!visible) { - // the block method must be called before $(#main) unloaded. - scrollBlocker.block(); - resultWrapper.removeClass("unloaded"); - main.addClass("unloaded"); - visible = true; - } - }, - off() { - if (visible) { - results.empty(); - if (hints.hasClass("unloaded")) { - hints.removeClass("unloaded"); - } - resultWrapper.addClass("unloaded"); - main.removeClass("unloaded"); + return { + on() { + if (!visible) { + // the block method must be called before $(#main) unloaded. + scrollBlocker.block(); + resultWrapper.removeClass("unloaded"); + main.addClass("unloaded"); + visible = true; + } + }, + off() { + if (visible) { + results.empty(); + if (hints.hasClass("unloaded")) { + hints.removeClass("unloaded"); + } + resultWrapper.addClass("unloaded"); + main.removeClass("unloaded"); - // now the release method must be called after $(#main) display - scrollBlocker.release(); + // now the release method must be called after $(#main) display + scrollBlocker.release(); - input.val(""); - visible = false; - } - }, - isVisible() { - return visible; - } - }; + input.val(""); + visible = false; + } + }, + isVisible() { + return visible; + } + }; - }()); + }()); - function isMobileView() { - return btnCancel.hasClass("loaded"); - } - - btnSearchTrigger.click(function() { - mobileSearchBar.on(); - resultSwitch.on(); - input.focus(); - }); - - btnCancel.click(function() { - mobileSearchBar.off(); - resultSwitch.off(); - }); - - input.focus(function() { - searchWrapper.addClass("input-focus"); - }); - - input.focusout(function() { - searchWrapper.removeClass("input-focus"); - }); - - input.on("input", () => { - if (input.val() === "") { - if (isMobileView()) { - hints.removeClass("unloaded"); - } else { - resultSwitch.off(); - } - - } else { - resultSwitch.on(); - if (isMobileView()) { - hints.addClass("unloaded"); - } + function isMobileView() { + return btnCancel.hasClass("loaded"); } - }); + + btnSearchTrigger.click(function () { + mobileSearchBar.on(); + resultSwitch.on(); + input.focus(); + }); + + btnCancel.click(function () { + mobileSearchBar.off(); + resultSwitch.off(); + }); + + input.focus(function () { + searchWrapper.addClass("input-focus"); + }); + + input.focusout(function () { + searchWrapper.removeClass("input-focus"); + }); + + input.on("input", () => { + if (input.val() === "") { + if (isMobileView()) { + hints.removeClass("unloaded"); + } else { + resultSwitch.off(); + } + + } else { + resultSwitch.on(); + if (isMobileView()) { + hints.addClass("unloaded"); + } + } + }); }); diff --git a/_javascript/commons/sidebar.js b/_javascript/commons/sidebar.js index 014411a..121353f 100644 --- a/_javascript/commons/sidebar.js +++ b/_javascript/commons/sidebar.js @@ -2,29 +2,27 @@ * Expand or close the sidebar in mobile screens. */ -$(function() { +$(function () { + const sidebarUtil = (function () { + const ATTR_DISPLAY = "sidebar-display"; + let isExpanded = false; + const body = $("body"); - const sidebarUtil = (function () { - const ATTR_DISPLAY = "sidebar-display"; - let isExpanded = false; - const body = $("body"); + return { + toggle() { + if (isExpanded === false) { + body.attr(ATTR_DISPLAY, ""); + } else { + body.removeAttr(ATTR_DISPLAY); + } - return { - toggle() { - if (isExpanded === false) { - body.attr(ATTR_DISPLAY, ""); - } else { - body.removeAttr(ATTR_DISPLAY); - } + isExpanded = !isExpanded; + } + }; - isExpanded = !isExpanded; - } - }; + }()); - }()); - - $("#sidebar-trigger").click(sidebarUtil.toggle); - - $("#mask").click(sidebarUtil.toggle); + $("#sidebar-trigger").click(sidebarUtil.toggle); + $("#mask").click(sidebarUtil.toggle); }); diff --git a/_javascript/commons/tooltip-loader.js b/_javascript/commons/tooltip-loader.js index 90c6a98..0b2f0b1 100644 --- a/_javascript/commons/tooltip-loader.js +++ b/_javascript/commons/tooltip-loader.js @@ -1,6 +1,6 @@ /** * Initial Bootstrap Tooltip. -*/ + */ $(function () { - $("[data-toggle=\"tooltip\"]").tooltip(); + $("[data-toggle=\"tooltip\"]").tooltip(); }); diff --git a/_javascript/commons/topbar-switcher.js b/_javascript/commons/topbar-switcher.js index f1c42bf..91c857e 100644 --- a/_javascript/commons/topbar-switcher.js +++ b/_javascript/commons/topbar-switcher.js @@ -1,90 +1,89 @@ -/* +/** * Hide Header on scroll down */ -$(function() { - const $searchInput = $("#search-input"); - const delta = ScrollHelper.getTopbarHeight(); +$(function () { + const $searchInput = $("#search-input"); + const delta = ScrollHelper.getTopbarHeight(); - let didScroll; - let lastScrollTop = 0; + let didScroll; + let lastScrollTop = 0; - function hasScrolled() { - let st = $(this).scrollTop(); + function hasScrolled() { + let st = $(this).scrollTop(); - /* Make sure they scroll more than delta */ - if (Math.abs(lastScrollTop - st) <= delta) { - return; - } - - if (st > lastScrollTop ) { // Scroll Down - ScrollHelper.hideTopbar(); - - if ($searchInput.is(":focus")) { - $searchInput.blur(); /* remove focus */ - } - - } else { // Scroll up - // has not yet scrolled to the bottom of the screen, that is, there is still space for scrolling - if (st + $(window).height() < $(document).height()) { - - if (ScrollHelper.hasScrollUpTask()) { - return; + /* Make sure they scroll more than delta */ + if (Math.abs(lastScrollTop - st) <= delta) { + return; } - if (ScrollHelper.topbarLocked()) { // avoid redundant scroll up event from smooth scrolling - ScrollHelper.unlockTopbar(); - } else { - if (ScrollHelper.orientationLocked()) { // avoid device auto scroll up on orientation change - ScrollHelper.unLockOrientation(); - } else { - ScrollHelper.showTopbar(); - } + if (st > lastScrollTop) { // Scroll Down + ScrollHelper.hideTopbar(); + + if ($searchInput.is(":focus")) { + $searchInput.blur(); /* remove focus */ + } + + } else { // Scroll up + // has not yet scrolled to the bottom of the screen, that is, there is still space for scrolling + if (st + $(window).height() < $(document).height()) { + + if (ScrollHelper.hasScrollUpTask()) { + return; + } + + if (ScrollHelper.topbarLocked()) { // avoid redundant scroll up event from smooth scrolling + ScrollHelper.unlockTopbar(); + } else { + if (ScrollHelper.orientationLocked()) { // avoid device auto scroll up on orientation change + ScrollHelper.unLockOrientation(); + } else { + ScrollHelper.showTopbar(); + } + } + } } - } + + lastScrollTop = st; + + } // hasScrolled() + + function handleLandscape() { + if ($(window).scrollTop() === 0) { + return; + } + ScrollHelper.lockOrientation(); + ScrollHelper.hideTopbar(); } - lastScrollTop = st; + if (screen.orientation) { + screen.orientation.onchange = () => { + const type = screen.orientation.type; + if (type === "landscape-primary" || type === "landscape-secondary") { + handleLandscape(); + } + }; - } // hasScrolled() - - function handleLandscape() { - if ($(window).scrollTop() === 0) { - return; + } else { + // for the browsers that not support `window.screen.orientation` API + $(window).on("orientationchange", () => { + if ($(window).width() < $(window).height()) { // before rotating, it is still in portrait mode. + handleLandscape(); + } + }); } - ScrollHelper.lockOrientation(); - ScrollHelper.hideTopbar(); - } - if (screen.orientation) { - screen.orientation.onchange = () => { - const type = screen.orientation.type; - if (type === "landscape-primary" || type === "landscape-secondary") { - handleLandscape(); - } - }; - - } else { - // for the browsers that not support `window.screen.orientation` API - $(window).on("orientationchange",() => { - if ($(window).width() < $(window).height()) { // before rotating, it is still in portrait mode. - handleLandscape(); - } + $(window).scroll(() => { + if (didScroll) { + return; + } + didScroll = true; }); - } - - $(window).scroll(() => { - if (didScroll) { - return; - } - didScroll = true; - }); - - setInterval(() => { - if (didScroll) { - hasScrolled(); - didScroll = false; - } - }, 250); + setInterval(() => { + if (didScroll) { + hasScrolled(); + didScroll = false; + } + }, 250); }); diff --git a/_javascript/commons/topbar-title.js b/_javascript/commons/topbar-title.js index ff82151..fd27a7d 100644 --- a/_javascript/commons/topbar-title.js +++ b/_javascript/commons/topbar-title.js @@ -1,67 +1,67 @@ -/* +/** * Top bar title auto change while scrolling up/down in mobile screens. -*/ + */ -$(function() { - const titleSelector = "div.post>h1:first-of-type"; - const $pageTitle = $(titleSelector); - const $topbarTitle = $("#topbar-title"); +$(function () { + const titleSelector = "div.post>h1:first-of-type"; + const $pageTitle = $(titleSelector); + const $topbarTitle = $("#topbar-title"); - if ($pageTitle.length === 0 /* on Home page */ - || $pageTitle.hasClass("dynamic-title") - || $topbarTitle.is(":hidden")) {/* not in mobile views */ - return; - } - - const defaultTitleText = $topbarTitle.text().trim(); - let pageTitleText = $pageTitle.text().trim(); - let hasScrolled = false; - let lastScrollTop = 0; - - if ($("#page-category").length || $("#page-tag").length) { - /* The title in Category or Tag page will be " <count_of_posts>" */ - if (/\s/.test(pageTitleText)) { - pageTitleText = pageTitleText.replace(/[0-9]/g, "").trim(); - } - } - - // When the page is scrolled down and then refreshed, the topbar title needs to be initialized - if ($pageTitle.offset().top < $(window).scrollTop()) { - $topbarTitle.text(pageTitleText); - } - - let options = { - rootMargin: '-48px 0px 0px 0px', // 48px equals to the topbar height (3rem) - threshold: [0, 1] - }; - - let observer = new IntersectionObserver((entries) => { - if (!hasScrolled) { - hasScrolled = true; - return; + if ($pageTitle.length === 0 /* on Home page */ + || $pageTitle.hasClass("dynamic-title") + || $topbarTitle.is(":hidden")) {/* not in mobile views */ + return; } - let curScrollTop = $(window).scrollTop(); - let isScrollDown = lastScrollTop < curScrollTop; - lastScrollTop = curScrollTop; - let heading = entries[0]; + const defaultTitleText = $topbarTitle.text().trim(); + let pageTitleText = $pageTitle.text().trim(); + let hasScrolled = false; + let lastScrollTop = 0; - if (isScrollDown) { - if (heading.intersectionRatio === 0) { + if ($("#page-category").length || $("#page-tag").length) { + /* The title in Category or Tag page will be "<title> <count_of_posts>" */ + if (/\s/.test(pageTitleText)) { + pageTitleText = pageTitleText.replace(/[0-9]/g, "").trim(); + } + } + + // When the page is scrolled down and then refreshed, the topbar title needs to be initialized + if ($pageTitle.offset().top < $(window).scrollTop()) { $topbarTitle.text(pageTitleText); - } - } else { - if (heading.intersectionRatio === 1) { - $topbarTitle.text(defaultTitleText); - } } - }, options); - observer.observe(document.querySelector(titleSelector)); + let options = { + rootMargin: '-48px 0px 0px 0px', // 48px equals to the topbar height (3rem) + threshold: [0, 1] + }; - /* Click title will scroll to top */ - $topbarTitle.click(function() { - $("body,html").animate({scrollTop: 0}, 800); - }); + let observer = new IntersectionObserver((entries) => { + if (!hasScrolled) { + hasScrolled = true; + return; + } + + let curScrollTop = $(window).scrollTop(); + let isScrollDown = lastScrollTop < curScrollTop; + lastScrollTop = curScrollTop; + let heading = entries[0]; + + if (isScrollDown) { + if (heading.intersectionRatio === 0) { + $topbarTitle.text(pageTitleText); + } + } else { + if (heading.intersectionRatio === 1) { + $topbarTitle.text(defaultTitleText); + } + } + }, options); + + observer.observe(document.querySelector(titleSelector)); + + /* Click title will scroll to top */ + $topbarTitle.click(function () { + $("body,html").animate({scrollTop: 0}, 800); + }); }); diff --git a/_javascript/copyright b/_javascript/copyright index 965aab6..c8063f6 100644 --- a/_javascript/copyright +++ b/_javascript/copyright @@ -1,5 +1,5 @@ /*! - * Chirpy v5.3.0 (https://github.com/cotes2020/jekyll-theme-chirpy/) + * Chirpy v5.3.1 (https://github.com/cotes2020/jekyll-theme-chirpy/) * © 2019 Cotes Chung * MIT Licensed */ diff --git a/_javascript/utils/category-collapse.js b/_javascript/utils/category-collapse.js index 904b448..965bcfd 100644 --- a/_javascript/utils/category-collapse.js +++ b/_javascript/utils/category-collapse.js @@ -1,30 +1,30 @@ -/* +/** * Tab 'Categories' expand/close effect. */ -$(function() { - const childPrefix = "l_"; - const parentPrefix = "h_"; - const collapse = $(".collapse"); +$(function () { + const childPrefix = "l_"; + const parentPrefix = "h_"; + const collapse = $(".collapse"); - /* close up top-category */ - collapse.on("hide.bs.collapse", function () { /* Bootstrap collapse events. */ - const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length); - if (parentId) { - $(`#${parentId} .far.fa-folder-open`).attr("class", "far fa-folder fa-fw"); - $(`#${parentId} i.fas`).addClass("rotate"); - $(`#${parentId}`).removeClass("hide-border-bottom"); - } - }); + /* close up top-category */ + collapse.on("hide.bs.collapse", function () { /* Bootstrap collapse events. */ + const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length); + if (parentId) { + $(`#${parentId} .far.fa-folder-open`).attr("class", "far fa-folder fa-fw"); + $(`#${parentId} i.fas`).addClass("rotate"); + $(`#${parentId}`).removeClass("hide-border-bottom"); + } + }); - /* expand the top category */ - collapse.on("show.bs.collapse", function() { - const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length); - if (parentId) { - $(`#${parentId} .far.fa-folder`).attr("class", "far fa-folder-open fa-fw"); - $(`#${parentId} i.fas`).removeClass("rotate"); - $(`#${parentId}`).addClass("hide-border-bottom"); - } - }); + /* expand the top category */ + collapse.on("show.bs.collapse", function () { + const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length); + if (parentId) { + $(`#${parentId} .far.fa-folder`).attr("class", "far fa-folder-open fa-fw"); + $(`#${parentId} i.fas`).removeClass("rotate"); + $(`#${parentId}`).addClass("hide-border-bottom"); + } + }); }); diff --git a/_javascript/utils/checkbox.js b/_javascript/utils/checkbox.js deleted file mode 100644 index b600d0a..0000000 --- a/_javascript/utils/checkbox.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Create a more beautiful checkbox - */ - -$(function() { - /* hide browser default checkbox */ - $("input[type=checkbox]").addClass("unloaded"); - /* create checked checkbox */ - $("input[type=checkbox][checked]").before("<i class=\"fas fa-check-circle checked\"></i>"); - /* create normal checkbox */ - $("input[type=checkbox]:not([checked])").before("<i class=\"far fa-circle\"></i>"); -}); diff --git a/_javascript/utils/clipboard.js b/_javascript/utils/clipboard.js index fb2899d..1b5001b 100644 --- a/_javascript/utils/clipboard.js +++ b/_javascript/utils/clipboard.js @@ -1,4 +1,4 @@ -/* +/** * Clipboard functions * * Dependencies: @@ -6,128 +6,128 @@ * - clipboard.js (https://github.com/zenorocha/clipboard.js) */ -$(function() { - const btnSelector = '.code-header>button'; - const ICON_SUCCESS = 'fas fa-check'; - const ATTR_TIMEOUT = 'timeout'; - const ATTR_TITLE_SUCCEED = 'data-title-succeed'; - const ATTR_TITLE_ORIGIN = 'data-original-title'; - const TIMEOUT = 2000; // in milliseconds +$(function () { + const btnSelector = '.code-header>button'; + const ICON_SUCCESS = 'fas fa-check'; + const ATTR_TIMEOUT = 'timeout'; + const ATTR_TITLE_SUCCEED = 'data-title-succeed'; + const ATTR_TITLE_ORIGIN = 'data-original-title'; + const TIMEOUT = 2000; // in milliseconds - function isLocked(node) { - if ($(node)[0].hasAttribute(ATTR_TIMEOUT)) { - let timeout = $(node).attr(ATTR_TIMEOUT); - if (Number(timeout) > Date.now()) { - return true; - } - } - return false; - } - - function lock(node) { - $(node).attr(ATTR_TIMEOUT, Date.now() + TIMEOUT); - } - - function unlock(node) { - $(node).removeAttr(ATTR_TIMEOUT); - } - - /* --- Copy code block --- */ - - // Initial the clipboard.js object - const clipboard = new ClipboardJS(btnSelector, { - target(trigger) { - let codeBlock = trigger.parentNode.nextElementSibling; - return codeBlock.querySelector('code .rouge-code'); - } - }); - - $(btnSelector).tooltip({ - trigger: 'hover', - placement: 'left' - }); - - function getIcon(btn) { - let iconNode = $(btn).children(); - return iconNode.attr('class'); - } - - const ICON_DEFAULT = getIcon(btnSelector); - - function showTooltip(btn) { - const succeedTitle = $(btn).attr(ATTR_TITLE_SUCCEED); - $(btn).attr(ATTR_TITLE_ORIGIN, succeedTitle).tooltip('show'); - } - - function hideTooltip(btn) { - $(btn).tooltip('hide').removeAttr(ATTR_TITLE_ORIGIN); - } - - function setSuccessIcon(btn) { - let btnNode = $(btn); - let iconNode = btnNode.children(); - iconNode.attr('class', ICON_SUCCESS); - } - - function resumeIcon(btn) { - let btnNode = $(btn); - let iconNode = btnNode.children(); - iconNode.attr('class', ICON_DEFAULT); - } - - clipboard.on('success', (e) => { - e.clearSelection(); - - const trigger = e.trigger; - if (isLocked(trigger)) { - return; + function isLocked(node) { + if ($(node)[0].hasAttribute(ATTR_TIMEOUT)) { + let timeout = $(node).attr(ATTR_TIMEOUT); + if (Number(timeout) > Date.now()) { + return true; + } + } + return false; } - setSuccessIcon(trigger); - showTooltip(trigger); - lock(trigger); - - setTimeout(() => { - hideTooltip(trigger); - resumeIcon(trigger); - unlock(trigger); - }, TIMEOUT); - - }); - - /* --- Post link sharing --- */ - - $('#copy-link').click((e) => { - - let target = $(e.target); - - if (isLocked(target)) { - return; + function lock(node) { + $(node).attr(ATTR_TIMEOUT, Date.now() + TIMEOUT); } - // Copy URL to clipboard + function unlock(node) { + $(node).removeAttr(ATTR_TIMEOUT); + } - const url = window.location.href; - const $temp = $("<input>"); + /* --- Copy code block --- */ - $("body").append($temp); - $temp.val(url).select(); - document.execCommand("copy"); - $temp.remove(); + // Initial the clipboard.js object + const clipboard = new ClipboardJS(btnSelector, { + target(trigger) { + let codeBlock = trigger.parentNode.nextElementSibling; + return codeBlock.querySelector('code .rouge-code'); + } + }); - // Switch tooltip title + $(btnSelector).tooltip({ + trigger: 'hover', + placement: 'left' + }); - const defaultTitle = target.attr(ATTR_TITLE_ORIGIN); - const succeedTitle = target.attr(ATTR_TITLE_SUCCEED); + function getIcon(btn) { + let iconNode = $(btn).children(); + return iconNode.attr('class'); + } - target.attr(ATTR_TITLE_ORIGIN, succeedTitle).tooltip('show'); - lock(target); + const ICON_DEFAULT = getIcon(btnSelector); - setTimeout(() => { - target.attr(ATTR_TITLE_ORIGIN, defaultTitle); - unlock(target); - }, TIMEOUT); + function showTooltip(btn) { + const succeedTitle = $(btn).attr(ATTR_TITLE_SUCCEED); + $(btn).attr(ATTR_TITLE_ORIGIN, succeedTitle).tooltip('show'); + } - }); + function hideTooltip(btn) { + $(btn).tooltip('hide').removeAttr(ATTR_TITLE_ORIGIN); + } + + function setSuccessIcon(btn) { + let btnNode = $(btn); + let iconNode = btnNode.children(); + iconNode.attr('class', ICON_SUCCESS); + } + + function resumeIcon(btn) { + let btnNode = $(btn); + let iconNode = btnNode.children(); + iconNode.attr('class', ICON_DEFAULT); + } + + clipboard.on('success', (e) => { + e.clearSelection(); + + const trigger = e.trigger; + if (isLocked(trigger)) { + return; + } + + setSuccessIcon(trigger); + showTooltip(trigger); + lock(trigger); + + setTimeout(() => { + hideTooltip(trigger); + resumeIcon(trigger); + unlock(trigger); + }, TIMEOUT); + + }); + + /* --- Post link sharing --- */ + + $('#copy-link').click((e) => { + + let target = $(e.target); + + if (isLocked(target)) { + return; + } + + // Copy URL to clipboard + + const url = window.location.href; + const $temp = $("<input>"); + + $("body").append($temp); + $temp.val(url).select(); + document.execCommand("copy"); + $temp.remove(); + + // Switch tooltip title + + const defaultTitle = target.attr(ATTR_TITLE_ORIGIN); + const succeedTitle = target.attr(ATTR_TITLE_SUCCEED); + + target.attr(ATTR_TITLE_ORIGIN, succeedTitle).tooltip('show'); + lock(target); + + setTimeout(() => { + target.attr(ATTR_TITLE_ORIGIN, defaultTitle); + unlock(target); + }, TIMEOUT); + + }); }); diff --git a/_javascript/utils/img-extra.js b/_javascript/utils/img-extra.js index efdb4d4..528f867 100644 --- a/_javascript/utils/img-extra.js +++ b/_javascript/utils/img-extra.js @@ -1,47 +1,46 @@ /** - Lazy load images (https://github.com/ApoorvSaxena/lozad.js) - and popup when clicked (https://github.com/dimsemenov/Magnific-Popup) -*/ + Lazy load images (https://github.com/ApoorvSaxena/lozad.js) + and popup when clicked (https://github.com/dimsemenov/Magnific-Popup) + */ -$(function() { +$(function () { + const IMG_SCOPE = '#main > div.row:first-child > div:first-child'; - const IMG_SCOPE = '#main > div.row:first-child > div:first-child'; - - if ($(`${IMG_SCOPE} img`).length <= 0 ) { - return; - } - - /* lazy loading */ - - const imgList = document.querySelectorAll(`${IMG_SCOPE} img[data-src]`); - const observer = lozad(imgList); - observer.observe(); - - /* popup */ - - $(`${IMG_SCOPE} p > img[data-src],${IMG_SCOPE} img[data-src].preview-img`).each( - function() { - let nextTag = $(this).next(); - const title = nextTag.prop('tagName') === 'EM' ? nextTag.text() : ''; - const src = $(this).attr('data-src'); // created by lozad.js - - $(this).wrap(`<a href="${src}" title="${title}" class="popup"></a>`); + if ($(`${IMG_SCOPE} img`).length <= 0) { + return; } - ); - $('.popup').magnificPopup({ - type: 'image', - closeOnContentClick: true, - showCloseBtn: false, - zoom: { - enabled: true, - duration: 300, - easing: 'ease-in-out' - } - }); + /* lazy loading */ - /* markup the image links */ + const imgList = document.querySelectorAll(`${IMG_SCOPE} img[data-src]`); + const observer = lozad(imgList); + observer.observe(); - $(`${IMG_SCOPE} a`).has('img').addClass('img-link'); + /* popup */ + + $(`${IMG_SCOPE} p > img[data-src], ${IMG_SCOPE} img[data-src].preview-img`).each( + function () { + let nextTag = $(this).next(); + const title = nextTag.prop('tagName') === 'EM' ? nextTag.text() : ''; + const src = $(this).attr('data-src'); // created by lozad.js + + $(this).wrap(`<a href="${src}" title="${title}" class="popup"></a>`); + } + ); + + $('.popup').magnificPopup({ + type: 'image', + closeOnContentClick: true, + showCloseBtn: false, + zoom: { + enabled: true, + duration: 300, + easing: 'ease-in-out' + } + }); + + /* markup the image links */ + + $(`${IMG_SCOPE} a`).has('img').addClass('img-link'); }); diff --git a/_javascript/utils/locale-datetime.js b/_javascript/utils/locale-datetime.js index 571dd0f..80d86c9 100644 --- a/_javascript/utils/locale-datetime.js +++ b/_javascript/utils/locale-datetime.js @@ -6,40 +6,38 @@ /* A tool for locale datetime */ const LocaleHelper = (function () { - const $preferLocale = $('meta[name="prefer-datetime-locale"]'); - const locale = $preferLocale.length > 0 ? - $preferLocale.attr('content').toLowerCase() : $('html').attr('lang').substr(0, 2); - const attrTimestamp = 'data-ts'; - const attrDateFormat = 'data-df'; + const locale = $('html').attr('lang').substr(0, 2); + const attrTimestamp = 'data-ts'; + const attrDateFormat = 'data-df'; - return { - locale: () => locale, - attrTimestamp: () => attrTimestamp, - attrDateFormat: () => attrDateFormat, - getTimestamp: ($elem) => Number($elem.attr(attrTimestamp)), // unix timestamp - getDateFormat: ($elem) => $elem.attr(attrDateFormat) - }; + return { + locale: () => locale, + attrTimestamp: () => attrTimestamp, + attrDateFormat: () => attrDateFormat, + getTimestamp: ($elem) => Number($elem.attr(attrTimestamp)), // unix timestamp + getDateFormat: ($elem) => $elem.attr(attrDateFormat) + }; }()); -$(function() { - dayjs.locale(LocaleHelper.locale()); - dayjs.extend(window.dayjs_plugin_localizedFormat); +$(function () { + dayjs.locale(LocaleHelper.locale()); + dayjs.extend(window.dayjs_plugin_localizedFormat); - $(`[${LocaleHelper.attrTimestamp()}]`).each(function () { - const date = dayjs.unix(LocaleHelper.getTimestamp($(this))); - const text = date.format(LocaleHelper.getDateFormat($(this))); - $(this).text(text); - $(this).removeAttr(LocaleHelper.attrTimestamp()); - $(this).removeAttr(LocaleHelper.attrDateFormat()); + $(`[${LocaleHelper.attrTimestamp()}]`).each(function () { + const date = dayjs.unix(LocaleHelper.getTimestamp($(this))); + const text = date.format(LocaleHelper.getDateFormat($(this))); + $(this).text(text); + $(this).removeAttr(LocaleHelper.attrTimestamp()); + $(this).removeAttr(LocaleHelper.attrDateFormat()); - // setup tooltips - const tooltip = $(this).attr('data-toggle'); - if (typeof tooltip === 'undefined' || tooltip !== 'tooltip') { - return; - } + // setup tooltips + const tooltip = $(this).attr('data-toggle'); + if (typeof tooltip === 'undefined' || tooltip !== 'tooltip') { + return; + } - const tooltipText = date.format('llll'); // see: https://day.js.org/docs/en/display/format#list-of-localized-formats - $(this).attr('data-original-title', tooltipText); - }); + const tooltipText = date.format('llll'); // see: https://day.js.org/docs/en/display/format#list-of-localized-formats + $(this).attr('data-original-title', tooltipText); + }); }); diff --git a/_javascript/utils/pageviews.js b/_javascript/utils/pageviews.js index 1b71508..1e875d8 100644 --- a/_javascript/utils/pageviews.js +++ b/_javascript/utils/pageviews.js @@ -1,4 +1,4 @@ -/* +/** * Count page views form GA or local cache file. * * Dependencies: @@ -7,244 +7,244 @@ */ const getInitStatus = (function () { - let hasInit = false; - return () => { - let ret = hasInit; - if (!hasInit) { - hasInit = true; - } - return ret; - }; + let hasInit = false; + return () => { + let ret = hasInit; + if (!hasInit) { + hasInit = true; + } + return ret; + }; }()); const PvOpts = (function () { - function getContent(selector) { - return $(selector).attr("content"); - } - - function hasContent(selector) { - let content = getContent(selector); - return (typeof content !== "undefined" && content !== false); - } - - return { - getProxyMeta() { - return getContent("meta[name=pv-proxy-endpoint]"); - }, - getLocalMeta() { - return getContent("meta[name=pv-cache-path]"); - }, - hasProxyMeta() { - return hasContent("meta[name=pv-proxy-endpoint]"); - }, - hasLocalMeta() { - return hasContent("meta[name=pv-cache-path]"); + function getContent(selector) { + return $(selector).attr("content"); } - }; + + function hasContent(selector) { + let content = getContent(selector); + return (typeof content !== "undefined" && content !== false); + } + + return { + getProxyMeta() { + return getContent("meta[name=pv-proxy-endpoint]"); + }, + getLocalMeta() { + return getContent("meta[name=pv-cache-path]"); + }, + hasProxyMeta() { + return hasContent("meta[name=pv-proxy-endpoint]"); + }, + hasLocalMeta() { + return hasContent("meta[name=pv-cache-path]"); + } + }; }()); const PvStorage = (function () { - const Keys = { - KEY_PV: "pv", - KEY_PV_SRC: "pv_src", - KEY_CREATION: "pv_created_date" - }; + const Keys = { + KEY_PV: "pv", + KEY_PV_SRC: "pv_src", + KEY_CREATION: "pv_created_date" + }; - const Source = { - LOCAL: "same-origin", - PROXY: "cors" - }; + const Source = { + LOCAL: "same-origin", + PROXY: "cors" + }; - function get(key) { - return localStorage.getItem(key); - } - - function set(key, val) { - localStorage.setItem(key, val); - } - - function saveCache(pv, src) { - set(Keys.KEY_PV, pv); - set(Keys.KEY_PV_SRC, src); - set(Keys.KEY_CREATION, new Date().toJSON()); - } - - return { - keysCount() { - return Object.keys(Keys).length; - }, - hasCache() { - return (localStorage.getItem(Keys.KEY_PV) !== null); - }, - getCache() { - return JSON.parse(localStorage.getItem(Keys.KEY_PV)); - }, - saveLocalCache(pv) { - saveCache(pv, Source.LOCAL); - }, - saveProxyCache(pv) { - saveCache(pv, Source.PROXY); - }, - isExpired() { - let date = new Date(get(Keys.KEY_CREATION)); - date.setHours(date.getHours() + 1); // per hour - return Date.now() >= date.getTime(); - }, - isFromLocal() { - return get(Keys.KEY_PV_SRC) === Source.LOCAL; - }, - isFromProxy() { - return get(Keys.KEY_PV_SRC) === Source.PROXY; - }, - newerThan(pv) { - return PvStorage.getCache().totalsForAllResults["ga:pageviews"] > pv.totalsForAllResults["ga:pageviews"]; - }, - inspectKeys() { - if (localStorage.length !== PvStorage.keysCount()) { - localStorage.clear(); - return; - } - - for(let i = 0; i < localStorage.length; i++){ - const key = localStorage.key(i); - switch (key) { - case Keys.KEY_PV: - case Keys.KEY_PV_SRC: - case Keys.KEY_CREATION: - break; - default: - localStorage.clear(); - return; - } - } + function get(key) { + return localStorage.getItem(key); } - }; + + function set(key, val) { + localStorage.setItem(key, val); + } + + function saveCache(pv, src) { + set(Keys.KEY_PV, pv); + set(Keys.KEY_PV_SRC, src); + set(Keys.KEY_CREATION, new Date().toJSON()); + } + + return { + keysCount() { + return Object.keys(Keys).length; + }, + hasCache() { + return (localStorage.getItem(Keys.KEY_PV) !== null); + }, + getCache() { + return JSON.parse(localStorage.getItem(Keys.KEY_PV)); + }, + saveLocalCache(pv) { + saveCache(pv, Source.LOCAL); + }, + saveProxyCache(pv) { + saveCache(pv, Source.PROXY); + }, + isExpired() { + let date = new Date(get(Keys.KEY_CREATION)); + date.setHours(date.getHours() + 1); // per hour + return Date.now() >= date.getTime(); + }, + isFromLocal() { + return get(Keys.KEY_PV_SRC) === Source.LOCAL; + }, + isFromProxy() { + return get(Keys.KEY_PV_SRC) === Source.PROXY; + }, + newerThan(pv) { + return PvStorage.getCache().totalsForAllResults["ga:pageviews"] > pv.totalsForAllResults["ga:pageviews"]; + }, + inspectKeys() { + if (localStorage.length !== PvStorage.keysCount()) { + localStorage.clear(); + return; + } + + for (let i = 0; i < localStorage.length; i++) { + const key = localStorage.key(i); + switch (key) { + case Keys.KEY_PV: + case Keys.KEY_PV_SRC: + case Keys.KEY_CREATION: + break; + default: + localStorage.clear(); + return; + } + } + } + }; }()); /* PvStorage */ function countUp(min, max, destId) { - if (min < max) { - let numAnim = new CountUp(destId, min, max); - if (!numAnim.error) { - numAnim.start(); - } else { - console.error(numAnim.error); + if (min < max) { + let numAnim = new CountUp(destId, min, max); + if (!numAnim.error) { + numAnim.start(); + } else { + console.error(numAnim.error); + } } - } } function countPV(path, rows) { - let count = 0; + let count = 0; - if (typeof rows !== "undefined" ) { - for (let i = 0; i < rows.length; ++i) { - const gaPath = rows[parseInt(i, 10)][0]; - if (gaPath === path) { /* path format see: site.permalink */ - count += parseInt(rows[parseInt(i, 10)][1], 10); - break; - } + if (typeof rows !== "undefined") { + for (let i = 0; i < rows.length; ++i) { + const gaPath = rows[parseInt(i, 10)][0]; + if (gaPath === path) { /* path format see: site.permalink */ + count += parseInt(rows[parseInt(i, 10)][1], 10); + break; + } + } } - } - return count; + return count; } function tacklePV(rows, path, elem, hasInit) { - let count = countPV(path, rows); - count = (count === 0 ? 1 : count); + let count = countPV(path, rows); + count = (count === 0 ? 1 : count); - if (!hasInit) { - elem.text(new Intl.NumberFormat().format(count)); - } else { - const initCount = parseInt(elem.text().replace(/,/g, ""), 10); - if (count > initCount) { - countUp(initCount, count, elem.attr("id")); + if (!hasInit) { + elem.text(new Intl.NumberFormat().format(count)); + } else { + const initCount = parseInt(elem.text().replace(/,/g, ""), 10); + if (count > initCount) { + countUp(initCount, count, elem.attr("id")); + } } - } } function displayPageviews(data) { - if (typeof data === "undefined") { - return; - } + if (typeof data === "undefined") { + return; + } - let hasInit = getInitStatus(); - const rows = data.rows; /* could be undefined */ + let hasInit = getInitStatus(); + const rows = data.rows; /* could be undefined */ - if ($("#post-list").length > 0) { /* the Home page */ - $(".post-preview").each(function() { - const path = $(this).find("a").attr("href"); - tacklePV(rows, path, $(this).find(".pageviews"), hasInit); - }); + if ($("#post-list").length > 0) { /* the Home page */ + $(".post-preview").each(function () { + const path = $(this).find("a").attr("href"); + tacklePV(rows, path, $(this).find(".pageviews"), hasInit); + }); - } else if ($(".post").length > 0) { /* the post */ - const path = window.location.pathname; - tacklePV(rows, path, $("#pv"), hasInit); - } + } else if ($(".post").length > 0) { /* the post */ + const path = window.location.pathname; + tacklePV(rows, path, $("#pv"), hasInit); + } } function fetchProxyPageviews() { - if (PvOpts.hasProxyMeta()) { - $.ajax({ - type: "GET", - url: PvOpts.getProxyMeta(), - dataType: "jsonp", - jsonpCallback: "displayPageviews", - success: (data) => { - PvStorage.saveProxyCache(JSON.stringify(data)); - }, - error: (jqXHR, textStatus, errorThrown) => { - console.log("Failed to load pageviews from proxy server: " + errorThrown); - } - }); - } + if (PvOpts.hasProxyMeta()) { + $.ajax({ + type: "GET", + url: PvOpts.getProxyMeta(), + dataType: "jsonp", + jsonpCallback: "displayPageviews", + success: (data) => { + PvStorage.saveProxyCache(JSON.stringify(data)); + }, + error: (jqXHR, textStatus, errorThrown) => { + console.log("Failed to load pageviews from proxy server: " + errorThrown); + } + }); + } } function fetchLocalPageviews(hasCache = false) { - return fetch(PvOpts.getLocalMeta()) - .then(response => response.json()) - .then(data => { - if (hasCache) { - // The cache from the proxy will sometimes be more recent than the local one - if (PvStorage.isFromProxy() && PvStorage.newerThan(data)) { - return; - } - } - displayPageviews(data); - PvStorage.saveLocalCache(JSON.stringify(data)); - }); + return fetch(PvOpts.getLocalMeta()) + .then(response => response.json()) + .then(data => { + if (hasCache) { + // The cache from the proxy will sometimes be more recent than the local one + if (PvStorage.isFromProxy() && PvStorage.newerThan(data)) { + return; + } + } + displayPageviews(data); + PvStorage.saveLocalCache(JSON.stringify(data)); + }); } -$(function() { - if ($(".pageviews").length <= 0) { - return; - } - - PvStorage.inspectKeys(); - - if (PvStorage.hasCache()) { - displayPageviews(PvStorage.getCache()); - - if (PvStorage.isExpired()) { - if (PvOpts.hasLocalMeta()) { - fetchLocalPageviews(true).then(fetchProxyPageviews); - } else { - fetchProxyPageviews(); - } - - } else { - if (PvStorage.isFromLocal()) { - fetchProxyPageviews(); - } +$(function () { + if ($(".pageviews").length <= 0) { + return; } - } else { // no cached + PvStorage.inspectKeys(); - if (PvOpts.hasLocalMeta()) { - fetchLocalPageviews().then(fetchProxyPageviews); - } else { - fetchProxyPageviews(); + if (PvStorage.hasCache()) { + displayPageviews(PvStorage.getCache()); + + if (PvStorage.isExpired()) { + if (PvOpts.hasLocalMeta()) { + fetchLocalPageviews(true).then(fetchProxyPageviews); + } else { + fetchProxyPageviews(); + } + + } else { + if (PvStorage.isFromLocal()) { + fetchProxyPageviews(); + } + } + + } else { // no cached + + if (PvOpts.hasLocalMeta()) { + fetchLocalPageviews().then(fetchProxyPageviews); + } else { + fetchProxyPageviews(); + } } - } }); diff --git a/_javascript/utils/smooth-scroll.js b/_javascript/utils/smooth-scroll.js index 200cb65..f8aba66 100644 --- a/_javascript/utils/smooth-scroll.js +++ b/_javascript/utils/smooth-scroll.js @@ -1,96 +1,96 @@ -/* - Safari doesn't support CSS `scroll-behavior: smooth`, - so here is a compatible solution for all browser to smooth scrolling +/** + Safari doesn't support CSS `scroll-behavior: smooth`, + so here is a compatible solution for all browser to smooth scrolling - See: <https://css-tricks.com/snippets/jquery/smooth-scrolling/> + See: <https://css-tricks.com/snippets/jquery/smooth-scrolling/> - Warning: It must be called after all `<a>` tags (e.g., the dynamic TOC) are ready. -*/ + Warning: It must be called after all `<a>` tags (e.g., the dynamic TOC) are ready. + */ -$(function() { - const $topbarTitle = $("#topbar-title"); - const REM = 16; // in pixels - const ATTR_SCROLL_FOCUS = "scroll-focus"; +$(function () { + const $topbarTitle = $("#topbar-title"); + const REM = 16; // in pixels + const ATTR_SCROLL_FOCUS = "scroll-focus"; - $("a[href*='#']") - .not("[href='#']") - .not("[href='#0']") - .click(function(event) { - if (this.pathname.replace(/^\//, "") !== - location.pathname.replace(/^\//, "")) { - return; - } + $("a[href*='#']") + .not("[href='#']") + .not("[href='#0']") + .click(function (event) { + if (this.pathname.replace(/^\//, "") !== + location.pathname.replace(/^\//, "")) { + return; + } - if (location.hostname !== this.hostname) { - return; - } + if (location.hostname !== this.hostname) { + return; + } - const hash = decodeURI(this.hash); - let toFootnoteRef = RegExp(/^#fnref:/).test(hash); - let toFootnote = toFootnoteRef ? false : RegExp(/^#fn:/).test(hash); - let selector = hash.includes(":") ? hash.replace(/\:/g, "\\:") : hash; - let $target = $(selector); + const hash = decodeURI(this.hash); + let toFootnoteRef = RegExp(/^#fnref:/).test(hash); + let toFootnote = toFootnoteRef ? false : RegExp(/^#fn:/).test(hash); + let selector = hash.includes(":") ? hash.replace(/:/g, "\\:") : hash; + let $target = $(selector); - let isMobileViews = $topbarTitle.is(":visible"); - let isPortrait = $(window).width() < $(window).height(); + let isMobileViews = $topbarTitle.is(":visible"); + let isPortrait = $(window).width() < $(window).height(); - if (typeof $target === "undefined") { - return; - } + if (typeof $target === "undefined") { + return; + } - event.preventDefault(); + event.preventDefault(); - if (history.pushState) { /* add hash to URL */ - history.pushState(null, null, hash); - } + if (history.pushState) { /* add hash to URL */ + history.pushState(null, null, hash); + } - let curOffset = $(window).scrollTop(); - let destOffset = $target.offset().top -= REM / 2; + let curOffset = $(window).scrollTop(); + let destOffset = $target.offset().top -= REM / 2; - if (destOffset < curOffset) { // scroll up - ScrollHelper.hideTopbar(); - ScrollHelper.addScrollUpTask(); + if (destOffset < curOffset) { // scroll up + ScrollHelper.hideTopbar(); + ScrollHelper.addScrollUpTask(); - if (isMobileViews && isPortrait) { - destOffset -= ScrollHelper.getTopbarHeight(); - } + if (isMobileViews && isPortrait) { + destOffset -= ScrollHelper.getTopbarHeight(); + } - } else { // scroll down - if (isMobileViews && isPortrait) { - destOffset -= ScrollHelper.getTopbarHeight(); - } - } + } else { // scroll down + if (isMobileViews && isPortrait) { + destOffset -= ScrollHelper.getTopbarHeight(); + } + } - $("html").animate({ - scrollTop: destOffset - }, 500, () => { - $target.focus(); + $("html").animate({ + scrollTop: destOffset + }, 500, () => { + $target.focus(); - /* clean up old scroll mark */ - if ($(`[${ATTR_SCROLL_FOCUS}=true]`).length) { - $(`[${ATTR_SCROLL_FOCUS}=true]`).attr(ATTR_SCROLL_FOCUS, false); - } + /* clean up old scroll mark */ + if ($(`[${ATTR_SCROLL_FOCUS}=true]`).length) { + $(`[${ATTR_SCROLL_FOCUS}=true]`).attr(ATTR_SCROLL_FOCUS, false); + } - /* Clean :target links */ - if ($(":target").length) { /* element that visited by the URL with hash */ - $(":target").attr(ATTR_SCROLL_FOCUS, false); - } + /* Clean :target links */ + if ($(":target").length) { /* element that visited by the URL with hash */ + $(":target").attr(ATTR_SCROLL_FOCUS, false); + } - /* set scroll mark to footnotes */ - if (toFootnote || toFootnoteRef) { - $target.attr(ATTR_SCROLL_FOCUS, true); - } + /* set scroll mark to footnotes */ + if (toFootnote || toFootnoteRef) { + $target.attr(ATTR_SCROLL_FOCUS, true); + } - if ($target.is(":focus")) { /* Checking if the target was focused */ - return false; - } else { - $target.attr("tabindex", "-1"); /* Adding tabindex for elements not focusable */ - $target.focus(); /* Set focus again */ - } + if ($target.is(":focus")) { /* Checking if the target was focused */ + return false; + } else { + $target.attr("tabindex", "-1"); /* Adding tabindex for elements not focusable */ + $target.focus(); /* Set focus again */ + } - if (ScrollHelper.hasScrollUpTask()) { - ScrollHelper.popScrollUpTask(); - } - }); - }); /* click() */ + if (ScrollHelper.hasScrollUpTask()) { + ScrollHelper.popScrollUpTask(); + } + }); + }); /* click() */ }); diff --git a/_layouts/archives.html b/_layouts/archives.html index 61ad91d..f86b417 100644 --- a/_layouts/archives.html +++ b/_layouts/archives.html @@ -3,15 +3,8 @@ layout: page # The Archives of posts. --- -{% include lang.html %} - -{% if site.prefer_datetime_locale == 'en' or lang == 'en' %} - {% assign df_strftime_m = '%b' %} - {% assign df_dayjs_m = 'MMM' %} -{% else %} - {% assign df_strftime_m = '/ %m' %} - {% assign df_dayjs_m = '/ MM' %} -{% endif %} +{% assign df_strftime_m = site.data.locales[site.lang].df.archives.strftime | default: '/ %m' %} +{% assign df_dayjs_m = site.data.locales[site.lang].df.archives.dayjs | default: '/ MM' %} <div id="archives" class="pl-xl-3"> diff --git a/_layouts/categories.html b/_layouts/categories.html index 88c45b0..b207186 100644 --- a/_layouts/categories.html +++ b/_layouts/categories.html @@ -3,8 +3,6 @@ layout: page # All the Categories of posts --- -{% include lang.html %} - {% assign HEAD_PREFIX = "h_" %} {% assign LIST_PREFIX = "l_" %} @@ -48,22 +46,22 @@ layout: page {% if sub_categories_size > 0 %} {{ sub_categories_size }} {% if sub_categories_size > 1 %} - {{ site.data.locales[lang].categories.category_measure.plural - | default: site.data.locales[lang].categories.category_measure }} + {{ site.data.locales[site.lang].categories.category_measure.plural + | default: site.data.locales[site.lang].categories.category_measure }} {% else %} - {{ site.data.locales[lang].categories.category_measure.singular - | default: site.data.locales[lang].categories.category_measure }} + {{ site.data.locales[site.lang].categories.category_measure.singular + | default: site.data.locales[site.lang].categories.category_measure }} {% endif %}, {% endif %} {{ top_posts_size }} {% if top_posts_size > 1 %} - {{ site.data.locales[lang].categories.post_measure.plural - | default: site.data.locales[lang].categories.post_measure }} + {{ site.data.locales[site.lang].categories.post_measure.plural + | default: site.data.locales[site.lang].categories.post_measure }} {% else %} - {{ site.data.locales[lang].categories.post_measure.singular - | default: site.data.locales[lang].categories.post_measure }} + {{ site.data.locales[site.lang].categories.post_measure.singular + | default: site.data.locales[site.lang].categories.post_measure }} {% endif %} </span> </span> @@ -99,11 +97,11 @@ layout: page {{ posts_size }} {% if posts_size > 1 %} - {{ site.data.locales[lang].categories.post_measure.plural - | default: site.data.locales[lang].categories.post_measure }} + {{ site.data.locales[site.lang].categories.post_measure.plural + | default: site.data.locales[site.lang].categories.post_measure }} {% else %} - {{ site.data.locales[lang].categories.post_measure.singular - | default: site.data.locales[lang].categories.post_measure }} + {{ site.data.locales[site.lang].categories.post_measure.singular + | default: site.data.locales[site.lang].categories.post_measure }} {% endif %} </span> </li> diff --git a/_layouts/category.html b/_layouts/category.html index f6ceb5a..07129bb 100644 --- a/_layouts/category.html +++ b/_layouts/category.html @@ -3,8 +3,6 @@ layout: page # The Category layout --- -{% include lang.html %} - <div id="page-category"> <h1 class="pl-lg-2"> <i class="far fa-folder-open fa-fw text-muted"></i> diff --git a/_layouts/default.html b/_layouts/default.html index 3823ba0..6d1b0a5 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -5,8 +5,6 @@ layout: compress <!DOCTYPE html> -{% include lang.html %} - {% include assets-origin.html %} {% capture prefer_mode %} @@ -15,7 +13,8 @@ layout: compress {% endif %} {% endcapture %} -<html lang="{{ site.lang }}"{{ prefer_mode }}> +<!-- `site.alt_lang` can specify a language different from the UI --> +<html lang="{{ site.alt_lang | default: site.lang }}"{{ prefer_mode }}> {% include head.html %} @@ -27,17 +26,15 @@ layout: compress <div id="main-wrapper" class="d-flex justify-content-center"> <div id="main" class="container pl-xl-4 pr-xl-4"> - {{ content }} - - {% include footer.html %} - </div> {% include search-results.html %} </div> <!-- #main-wrapper --> + {% include footer.html %} + {% if page.mermaid %} {% include mermaid.html %} {% endif %} @@ -57,9 +54,9 @@ layout: compress </button> </div> <div class="toast-body text-center pt-0"> - <p class="pl-2 pr-2 mb-3">{{ site.data.locales[lang].notification.update_found }}</p> + <p class="pl-2 pr-2 mb-3">{{ site.data.locales[site.lang].notification.update_found }}</p> <button type="button" class="btn btn-primary" aria-label="Update"> - {{ site.data.locales[lang].notification.update }} + {{ site.data.locales[site.lang].notification.update }} </button> </div> </div> diff --git a/_layouts/home.html b/_layouts/home.html index 903573b..9d9eae3 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -3,8 +3,6 @@ layout: page # The Home page layout --- -{% include lang.html %} - {% assign pinned = site.posts | where: "pin", "true" %} {% assign default = site.posts | where_exp: "item", "item.pin != true and item.hidden != true" %} @@ -79,7 +77,7 @@ layout: page {% if post.pin %} <div class="pin"> <i class="fas fa-thumbtack fa-fw"></i> - <span>{{ site.data.locales[lang].post.pin_prompt }}</span> + <span>{{ site.data.locales[site.lang].post.pin_prompt }}</span> </div> {% endif %} diff --git a/_layouts/page.html b/_layouts/page.html index d5597fb..4285c85 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -2,14 +2,12 @@ layout: default --- -{% include lang.html %} - {% include assets-origin.html %} <div class="row"> <!-- core --> - <div id="core-wrapper" class="col-12 col-lg-11 col-xl-9 pr-xl-4 pb-5"> + <div id="core-wrapper" class="col-12 col-lg-11 col-xl-9 pr-xl-4"> <div class="post pl-1 pr-1 pl-md-2 pr-md-2"> {% capture _content %} @@ -20,9 +18,9 @@ layout: default {% endif %} {% endcapture %} - {% if page.collection == 'tabs' %} + {% if page.layout == 'page' or page.collection == 'tabs' %} {% assign tab_key = page.title | downcase %} - {% assign title = site.data.locales[lang].tabs[tab_key] | default: page.title %} + {% assign title = site.data.locales[site.lang].tabs[tab_key] | default: page.title %} <h1 class="dynamic-title"> {{ title }} </h1> @@ -55,7 +53,7 @@ layout: default <!-- tail --> {% if layout.tail_includes %} <div class="row"> - <div id="tail-wrapper" class="col-12 col-lg-11 col-xl-9 pl-3 pr-3 pr-xl-4"> + <div id="tail-wrapper" class="col-12 col-lg-11 col-xl-9 pl-3 pr-3 pr-xl-4 mt-5"> {% for _include in layout.tail_includes %} {% assign _include_path = _include | append: '.html' %} {% include {{ _include_path }} %} diff --git a/_layouts/post.html b/_layouts/post.html index e3d922c..44de48a 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -9,21 +9,19 @@ tail_includes: - comments --- -{% include lang.html %} - <h1 data-toc-skip>{{ page.title }}</h1> <div class="post-meta text-muted"> <!-- published date --> <span> - {{ site.data.locales[lang].post.posted }} + {{ site.data.locales[site.lang].post.posted }} {% include datetime.html date=page.date tooltip=true %} </span> <!-- lastmod date --> {% if page.last_modified_at %} <span> - {{ site.data.locales[lang].post.updated }} + {{ site.data.locales[site.lang].post.updated }} {% include datetime.html date=page.last_modified_at tooltip=true %} </span> {% endif %} @@ -65,7 +63,7 @@ tail_includes: {% assign authors = page.authors %} {% endif %} - {{ site.data.locales[lang].post.written_by }} + {{ site.data.locales[site.lang].post.written_by }} <em> {% if authors %} @@ -86,7 +84,7 @@ tail_includes: <em id="pv" class="pageviews"> <i class="fas fa-spinner fa-spin fa-fw"></i> </em> - {{ site.data.locales[lang].post.pageview_measure }} + {{ site.data.locales[site.lang].post.pageview_measure }} </span> {% endif %} @@ -132,15 +130,15 @@ tail_includes: d-flex justify-content-between align-items-center mt-3 pt-5 pb-2"> <div class="license-wrapper"> - {% if site.data.locales[lang].copyright.license.template %} + {% if site.data.locales[site.lang].copyright.license.template %} {% capture _replacement %} - <a href="{{ site.data.locales[lang].copyright.license.link }}"> - {{ site.data.locales[lang].copyright.license.name }} + <a href="{{ site.data.locales[site.lang].copyright.license.link }}"> + {{ site.data.locales[site.lang].copyright.license.name }} </a> {% endcapture %} - {{ site.data.locales[lang].copyright.license.template | replace: ':LICENSE_NAME', _replacement }} + {{ site.data.locales[site.lang].copyright.license.template | replace: ':LICENSE_NAME', _replacement }} {% endif %} </div> diff --git a/_layouts/tag.html b/_layouts/tag.html index e29009d..5fd528f 100644 --- a/_layouts/tag.html +++ b/_layouts/tag.html @@ -3,8 +3,6 @@ layout: page # The layout for Tag page --- -{% include lang.html %} - <div id="page-tag"> <h1 class="pl-lg-2"> <i class="fa fa-tag fa-fw text-muted"></i> diff --git a/_posts/2019-08-08-text-and-typography.md b/_posts/2019-08-08-text-and-typography.md index 2a9e9ea..55e65c3 100644 --- a/_posts/2019-08-08-text-and-typography.md +++ b/_posts/2019-08-08-text-and-typography.md @@ -30,17 +30,7 @@ This post is to show Markdown syntax rendering on [**Chirpy**](https://github.co ## Paragraph -I wandered lonely as a cloud - -That floats on high o'er vales and hills, - -When all at once I saw a crowd, - -A host, of golden daffodils; - -Beside the lake, beneath the trees, - -Fluttering and dancing in the breeze. +Quisque egestas convallis ipsum, ut sollicitudin risus tincidunt a. Maecenas interdum malesuada egestas. Duis consectetur porta risus, sit amet vulputate urna facilisis ac. Phasellus semper dui non purus ultrices sodales. Aliquam ante lorem, ornare a feugiat ac, finibus nec mauris. Vivamus ut tristique nisi. Sed vel leo vulputate, efficitur risus non, posuere mi. Nullam tincidunt bibendum rutrum. Proin commodo ornare sapien. Vivamus interdum diam sed sapien blandit, sit amet aliquam risus mattis. Nullam arcu turpis, mollis quis laoreet at, placerat id nibh. Suspendisse venenatis eros eros. ## Lists @@ -53,17 +43,15 @@ Fluttering and dancing in the breeze. ### Unordered list - Chapter - - Section - - Paragraph + + Section + * Paragraph -### Task list +### ToDo list -- [ ] TODO -- [x] Completed -- [ ] Defeat COVID-19 - - [x] Vaccine production - - [ ] Economic recovery - - [ ] People smile again +- [ ] Job + + [x] Step 1 + + [x] Step 2 + + [ ] Step 3 ### Description list @@ -118,30 +106,24 @@ _Full screen width and center alignment_ - Shadow -![Window shadow](/posts/20190808/window.png){: .shadow width="1548" height="864" style="max-width: 90%" } +![Window shadow](/posts/20190808/window.png){: .shadow width="1548" height="864" .w-75 } _shadow effect (visible in light mode)_ <br> - Left aligned -![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" style="max-width: 70%" .normal} - -<br> +![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-75 .normal} - Float to left - ![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" style="max-width: 200px" .left} - "A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space." - -<br> + ![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .left} + Praesent maximus aliquam sapien. Sed vel neque in dolor pulvinar auctor. Maecenas pharetra, sem sit amet interdum posuere, tellus lacus eleifend magna, ac lobortis felis ipsum id sapien. Proin ornare rutrum metus, ac convallis diam volutpat sit amet. Phasellus volutpat, elit sit amet tincidunt mollis, felis mi scelerisque mauris, ut facilisis leo magna accumsan sapien. In rutrum vehicula nisl eget tempor. Nullam maximus ullamcorper libero non maximus. Integer ultricies velit id convallis varius. Praesent eu nisl eu urna finibus ultrices id nec ex. Mauris ac mattis quam. Fusce aliquam est nec sapien bibendum, vitae malesuada ligula condimentum. Phasellus a tortor aliquam, tristique felis sit amet, elementum enim. Integer vestibulum vitae nulla nec pretium. - Float to right - ![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" style="max-width: 200px" .right} - "A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space." - -<br> + ![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .right} + Praesent maximus aliquam sapien. Sed vel neque in dolor pulvinar auctor. Maecenas pharetra, sem sit amet interdum posuere, tellus lacus eleifend magna, ac lobortis felis ipsum id sapien. Proin ornare rutrum metus, ac convallis diam volutpat sit amet. Phasellus volutpat, elit sit amet tincidunt mollis, felis mi scelerisque mauris, ut facilisis leo magna accumsan sapien. In rutrum vehicula nisl eget tempor. Nullam maximus ullamcorper libero non maximus. Integer ultricies velit id convallis varius. Praesent eu nisl eu urna finibus ultrices id nec ex. Mauris ac mattis quam. Fusce aliquam est nec sapien bibendum, vitae malesuada ligula condimentum. Phasellus a tortor aliquam, tristique felis sit amet, elementum enim. Integer vestibulum vitae nulla nec pretium. ## Mermaid SVG diff --git a/_posts/2019-08-09-getting-started.md b/_posts/2019-08-09-getting-started.md index d1b9722..a88037d 100644 --- a/_posts/2019-08-09-getting-started.md +++ b/_posts/2019-08-09-getting-started.md @@ -113,7 +113,7 @@ Now publish your Jekyll site: 1. Browse to your repository on GitHub. Select the tab _Settings_, then click _Pages_ in the left navigation bar. Then, in the **Source** section (under _Build and deployment_), select [**GitHub Actions**][pages-workflow-src] from the dropdown menu. -2. Push any commit to remote to trigger the GitHub Actions workflow. In the _Actions_ tab of your repository, you should see the "Deploy Jekyll with GitHub Pages" workflow with at least one job running. Once the build is complete and successful, the site should be deployed automatically. +2. Push any commit to remote to trigger the GitHub Actions workflow. In the _Actions_ tab of your repository, you should see the workflow _Build and Deploy_ running. Once the build is complete and successful, the site should be deployed automatically. 3. Visit your website at the address indicated by GitHub. diff --git a/_sass/addon/commons.scss b/_sass/addon/commons.scss index ed55c75..a258516 100644 --- a/_sass/addon/commons.scss +++ b/_sass/addon/commons.scss @@ -5,22 +5,22 @@ html { @media (prefers-color-scheme: light) { &:not([data-mode]), - &[data-mode=light] { + &[data-mode="light"] { @include light-scheme; } - &[data-mode=dark] { + &[data-mode="dark"] { @include dark-scheme; } } @media (prefers-color-scheme: dark) { &:not([data-mode]), - &[data-mode=dark] { + &[data-mode="dark"] { @include dark-scheme; } - &[data-mode=light] { + &[data-mode="light"] { @include light-scheme; } } @@ -29,11 +29,11 @@ html { } body { - line-height: 1.75rem; background: var(--body-bg); color: var(--text-color); -webkit-font-smoothing: antialiased; - font-family: 'Source Sans Pro', 'Microsoft Yahei', sans-serif; + font-family: "Source Sans Pro", "Microsoft Yahei", sans-serif; + line-height: 1.75; } /* --- Typography --- */ @@ -76,14 +76,6 @@ h5 { font-size: 1.1rem; } -ol, -ul { - ol, - ul { - margin-bottom: 1rem; - } -} - a { @extend %link-color; } @@ -102,27 +94,28 @@ blockquote { display: flex; border-left: 0; border-radius: 6px; - padding: 0.75rem 1.2rem; + padding: 1rem; color: var(--prompt-text-color); &::before { - margin-right: 1rem; font-family: "Font Awesome 5 Free"; text-align: center; width: 1.25rem; + margin-right: 0.75rem; } - p:last-child { - margin-bottom: 0rem; + > div { + max-width: calc(100% - 2rem); + + > :last-child { + margin-bottom: 0; + } } } @include prompt("tip", "\f0eb", 400); - @include prompt("info", "\f06a"); - @include prompt("warning", "\f06a"); - @include prompt("danger", "\f071"); } @@ -148,11 +141,10 @@ kbd { } footer { - @include pl-pr(1.5rem); - font-size: 0.8rem; + background-color: var(--main-bg); - > div.d-flex { + div.d-flex { height: $footer-height; line-height: 1.2rem; padding-bottom: 1rem; @@ -172,7 +164,6 @@ footer { &:hover { @extend %link-hover; - @include no-text-decoration; } } @@ -189,6 +180,11 @@ i { /* fontawesome icons */ } } +@-webkit-keyframes fade-in { + from { opacity: 0; } + to { opacity: 1; } +} + @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } @@ -197,7 +193,8 @@ i { /* fontawesome icons */ img[data-src] { margin: 0.5rem 0; - &[data-loaded=true] { + &[data-loaded="true"] { + -webkit-animation: fade-in linear 0.5s; animation: fade-in linear 0.5s; } @@ -212,6 +209,7 @@ img[data-src] { } &.shadow { + -webkit-filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.08)); filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.08)); box-shadow: none !important; /* cover the Bootstrap 4.6.1 styles */ } @@ -228,7 +226,7 @@ img[data-src] { margin-bottom: 4rem; &:only-child { - position: -webkit-sticky; /* Safari */ + position: -webkit-sticky; position: sticky; } @@ -244,7 +242,6 @@ img[data-src] { .post-content { font-size: 0.9rem; } - } #panel-wrapper { @@ -266,12 +263,12 @@ img[data-src] { &:hover { background-color: #2a408e; border-color: #2a408e; - color: #fff; + color: #ffffff; transition: none; } } - [data-topbar-visible=true] & > div { + [data-topbar-visible="true"] & > div { top: 6rem; } } @@ -296,7 +293,6 @@ img[data-src] { color: inherit; } - } .footnotes > ol { @@ -316,10 +312,11 @@ img[data-src] { /* [scroll-focus] added by `smooth-scroll.js` */ &:target:not([scroll-focus]), - &[scroll-focus=true] > p { + &[scroll-focus="true"] > p { background-color: var(--footnote-target-bg); + width: -moz-fit-content; + width: -webkit-fit-content; width: fit-content; - -webkit-transition: background-color 1.5s ease-in-out; /* Safari prior 6.1 */ transition: background-color 1.5s ease-in-out; } } @@ -331,7 +328,6 @@ img[data-src] { @include pl-pr(2px); border-bottom-style: none !important; - -webkit-transition: background-color 1.5s ease-in-out; /* Safari prior 6.1 */ transition: background-color 1.5s ease-in-out; } @@ -421,7 +417,6 @@ img[data-src] { } } } /* a */ - } .pageviews .fa-spinner { @@ -449,10 +444,8 @@ img[data-src] { .post-content { font-size: 1.08rem; - line-height: 1.8; margin-top: 2rem; overflow-wrap: break-word; - word-wrap: break-word; a { &:not(.img-link) { @@ -466,17 +459,37 @@ img[data-src] { &.img-link { @extend %img-caption; } - } - ul { - /* attribute 'hide-bullet' was added by liquid */ - .task-list-item[hide-bullet] { + > ol, + > ul { + -webkit-padding-start: 1.75rem; + padding-inline-start: 1.75rem; + + li { + margin: 0.25rem 0; + padding-left: 0.25rem; + } + + ol, + ul { + -webkit-padding-start: 1rem; + padding-inline-start: 1rem; + margin: 0.5rem 0; + } + } + + ul.task-list { + -webkit-padding-start: 1.25rem; + padding-inline-start: 1.25rem; + + li { list-style-type: none; + padding-left: 0; > i { /* checkbox icon */ - margin: 0 0.4rem 0.2rem -1.4rem; - vertical-align: middle; + width: 2rem; + margin-left: -1.25rem; color: var(--checkbox-color); &.checked { @@ -484,39 +497,21 @@ img[data-src] { } } - } - - input[type=checkbox] { - margin: 0 0.5rem 0.2rem -1.3rem; - vertical-align: middle; - } - - } /* ul */ - - > ol, - > ul { - padding-left: 2rem; - - li { - ol, - ul { /* sub list */ - padding-left: 2rem; - margin-top: 0.3rem; + ul { + -webkit-padding-start: 1.75rem; + padding-inline-start: 1.75rem; } } - } - - > ol { - li { - padding-left: 0.25em; + input[type="checkbox"] { + margin: 0 0.5rem 0.2rem -1.3rem; + vertical-align: middle; } - } + } /* ul */ dl > dd { margin-left: 1rem; } - } /* .post-content */ .tag:hover { @@ -581,7 +576,6 @@ img[data-src] { } .flex-grow-1 { - -ms-flex-positive: 1 !important; flex-grow: 1 !important; } @@ -673,9 +667,8 @@ $sidebar-display: "sidebar-display"; border-radius: 50%; border: 2px solid rgba(222, 222, 222, 0.7); overflow: hidden; + -webkit-transform: translateZ(0); transform: translateZ(0); /* fixed the zoom in Safari */ - -webkit-transition: border-color 0.35s ease-in-out; - -moz-transition: border-color 0.35s ease-in-out; transition: border-color 0.35s ease-in-out; &:hover { @@ -686,13 +679,11 @@ $sidebar-display: "sidebar-display"; img { width: 100%; height: 100%; - -webkit-transition: transform 0.5s; - -moz-transition: transform 0.5s; + transition: -webkit-transform 0.5s; transition: transform 0.5s; + transition: transform 0.5s, -webkit-transform 0.5s; &:hover { - -ms-transform: scale(1.2); - -moz-transform: scale(1.2); -webkit-transform: scale(1.2); transform: scale(1.2); } @@ -700,23 +691,27 @@ $sidebar-display: "sidebar-display"; } /* #avatar */ .site-title { + margin-top: 0.55rem; + a { @extend %clickable-transition; font-weight: 900; font-size: 1.5rem; letter-spacing: 0.5px; - color: rgba(134, 133, 133, 99%); + color: rgba(134, 133, 133, 0.99); } } .site-subtitle { font-size: 95%; color: var(--sidebar-muted-color); - line-height: 1.2rem; + line-height: 1.25rem; word-spacing: 1px; - margin: 0.5rem 1.5rem 0.5rem 1.5rem; + margin: 0.2rem 1.5rem 0.5rem 1.5rem; min-height: 3rem; /* avoid vertical shifting in multi-line words */ + -webkit-user-select: none; + -moz-user-select: none; user-select: none; } @@ -797,9 +792,7 @@ $sidebar-display: "sidebar-display"; @include fix-cursor($top); } } - } /* @for */ - } /* ul */ .sidebar-bottom { @@ -850,16 +843,11 @@ $sidebar-display: "sidebar-display"; height: 3px; border-radius: 50%; } - } /* .sidebar-bottom */ - } /* #sidebar */ @media (hover: hover) { #sidebar ul > li:last-child::after { - -webkit-transition: top 0.5s ease; - -moz-transition: top 0.5s ease; - -o-transition: top 0.5s ease; transition: top 0.5s ease; } } @@ -893,14 +881,14 @@ $sidebar-display: "sidebar-display"; border-bottom: 1px solid rgba(0, 0, 0, 0.07); background-color: var(--topbar-wrapper-bg); - [data-topbar-visible=false] & { + [data-topbar-visible="false"] & { top: -$topbar-height; /* same as topbar height. */ } } #topbar { i { /* icons */ - color: #999; + color: #999999; } #breadcrumb { @@ -964,9 +952,8 @@ $sidebar-display: "sidebar-display"; background: center; &.form-control { - &::-webkit-input-placeholder { @include input-placeholder; } &::-moz-placeholder { @include input-placeholder; } - &:-ms-input-placeholder { @include input-placeholder; } + &::-webkit-input-placeholder { @include input-placeholder; } &::placeholder { @include input-placeholder; } } } @@ -1052,8 +1039,6 @@ $sidebar-display: "sidebar-display"; } #core-wrapper { - min-height: calc(100vh - #{$topbar-height} - #{$footer-height}); - .categories, #tags, #archives { @@ -1061,6 +1046,10 @@ $sidebar-display: "sidebar-display"; @extend %no-bottom-border; } } + + @at-root .row:only-child > #{&} { + padding-bottom: 3rem; + } } #mask { @@ -1082,9 +1071,9 @@ $sidebar-display: "sidebar-display"; /* --- main wrapper --- */ #main-wrapper { - background-color: var(--main-wrapper-bg); + background-color: var(--main-bg); position: relative; - min-height: 100vh; + min-height: calc(100vh - #{$footer-height}); @include pl-pr(0); } @@ -1116,7 +1105,9 @@ $sidebar-display: "sidebar-display"; height: $size; border-radius: 50%; border: 1px solid var(--btn-backtotop-border-color); + transition: -webkit-transform 0.2s ease-out; transition: transform 0.2s ease-out; + transition: transform 0.2s ease-out, -webkit-transform 0.2s ease-out; -webkit-transition: transform 0.2s ease-out; i { @@ -1132,6 +1123,13 @@ $sidebar-display: "sidebar-display"; } #notification { + @-webkit-keyframes popup { + from { + opacity: 0; + bottom: 0; + } + } + @keyframes popup { from { opacity: 0; @@ -1146,7 +1144,7 @@ $sidebar-display: "sidebar-display"; } .toast-body { - font-family: 'Lato'; + font-family: Lato, sans-serif; line-height: 1.25rem; button { @@ -1169,11 +1167,12 @@ $sidebar-display: "sidebar-display"; position: fixed; left: 50%; bottom: 20%; + -webkit-transform: translateX(-50%); transform: translateX(-50%); + -webkit-animation: popup 0.8s; animation: popup 0.8s; } } - } /* @@ -1189,10 +1188,9 @@ $sidebar-display: "sidebar-display"; footer { height: $footer-height-mobile; - > div.d-flex { + div.d-flex { padding: 1.5rem 0; flex-wrap: wrap; - -ms-flex-pack: distribute !important; justify-content: space-around !important; } @@ -1202,6 +1200,10 @@ $sidebar-display: "sidebar-display"; } } + #main-wrapper { + min-height: calc(100vh - #{$footer-height-mobile}); + } + #core-wrapper { min-height: calc(100vh - #{$topbar-height} - #{$footer-height-mobile}) !important; @@ -1211,12 +1213,14 @@ $sidebar-display: "sidebar-display"; } .post-content { - > blockquote[class^=prompt-] { + > blockquote[class^="prompt-"] { + @include pl-pr(1.25rem); @include ml-mr(-1.25rem); + border-radius: 0; + max-width: none; } } - } #avatar > a { @@ -1227,7 +1231,6 @@ $sidebar-display: "sidebar-display"; .site-subtitle { @include ml-mr(1.8rem); } - } @media all and (max-width: 768px) { @@ -1249,11 +1252,10 @@ $sidebar-display: "sidebar-display"; @media all and (max-width: 849px) { @mixin slide($append: null) { $basic: transform 0.4s ease; + @if $append { - -webkit-transition: $basic, $append; transition: $basic, $append; } @else { - -webkit-transition: $basic; transition: $basic; } } @@ -1263,13 +1265,20 @@ $sidebar-display: "sidebar-display"; overflow-x: hidden; } + footer { + @include slide; + } + [#{$sidebar-display}] { #sidebar { + -webkit-transform: translateX(0); transform: translateX(0); } #topbar-wrapper, - #main-wrapper { + #main-wrapper, + footer { + -webkit-transform: translateX(#{$sidebar-width}); transform: translateX(#{$sidebar-width}); } } @@ -1281,8 +1290,6 @@ $sidebar-display: "sidebar-display"; -webkit-transform: translateX(-#{$sidebar-width}); .cursor { - -webkit-transition: none; - -moz-transition: none; transition: none; } } @@ -1294,7 +1301,8 @@ $sidebar-display: "sidebar-display"; } #topbar, - #main { + #main, + footer > .container { max-width: 100%; } @@ -1329,8 +1337,6 @@ $sidebar-display: "sidebar-display"; } #tags { - -webkit-box-pack: center !important; - -ms-flex-pack: center !important; justify-content: center !important; } @@ -1341,18 +1347,17 @@ $sidebar-display: "sidebar-display"; margin-top: 3rem; } } - } /* max-width: 849px */ @media all and (max-width: 849px) and (orientation: portrait) { - [data-topbar-visible=false] #topbar-wrapper { + [data-topbar-visible="false"] #topbar-wrapper { top: 0; } } /* Phone & Pad */ @media all and (min-width: 577px) and (max-width: 1199px) { - footer > .d-flex > div { + footer .d-flex > div { width: 312px; } } @@ -1364,7 +1369,8 @@ $sidebar-display: "sidebar-display"; overflow-y: scroll; } - #main-wrapper { + #main-wrapper, + footer { margin-left: $sidebar-width; } @@ -1395,21 +1401,14 @@ $sidebar-display: "sidebar-display"; right: 5%; } - #topbar { - @include pl-pr(2rem); - } - #topbar-title { text-align: left; } - } /* Pad horizontal */ @media all and (min-width: 992px) and (max-width: 1199px) { #main .col-lg-11 { - -webkit-box-flex: 0; - -ms-flex: 0 0 96%; flex: 0 0 96%; max-width: 96%; } @@ -1438,7 +1437,7 @@ $sidebar-display: "sidebar-display"; } #topbar-wrapper { - left: 210px; + left: $sidebar-width-small; } #search-results > div { @@ -1456,8 +1455,9 @@ $sidebar-display: "sidebar-display"; font-size: 90%; } - #main-wrapper { - margin-left: 210px; + #main-wrapper, + footer { + margin-left: $sidebar-width-small; } #breadcrumb { @@ -1467,7 +1467,6 @@ $sidebar-display: "sidebar-display"; word-break: keep-all; white-space: nowrap; } - } /* panel hidden */ @@ -1477,8 +1476,6 @@ $sidebar-display: "sidebar-display"; } #main > div.row { - -webkit-box-pack: center !important; - -ms-flex-pack: center !important; justify-content: center !important; } } @@ -1495,7 +1492,6 @@ $sidebar-display: "sidebar-display"; } #search-input { - -webkit-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; } @@ -1520,10 +1516,11 @@ $sidebar-display: "sidebar-display"; font-size: 1.03rem; } - footer > div.d-felx { - width: 85%; + footer { + div.d-felx { + width: 85%; + } } - } @media all and (min-width: 1400px) { @@ -1533,7 +1530,8 @@ $sidebar-display: "sidebar-display"; } @media all and (min-width: 1650px) { - #main-wrapper { + #main-wrapper, + footer { margin-left: $sidebar-width-large; } @@ -1546,7 +1544,8 @@ $sidebar-display: "sidebar-display"; } #topbar, - #main { + #main, + footer > .container { max-width: $main-content-max-width; } @@ -1590,6 +1589,8 @@ $sidebar-display: "sidebar-display"; .site-title { @extend %profile-ml; + margin-top: 0.4rem; + a { font-size: 1.7rem; letter-spacing: 1px; @@ -1600,9 +1601,8 @@ $sidebar-display: "sidebar-display"; @extend %profile-ml; word-spacing: 0; - margin-top: 0.3rem; + margin-top: 0; } - } /* .profile-wrapper (min-width: 1650px) */ ul { @@ -1628,7 +1628,6 @@ $sidebar-display: "sidebar-display"; } } } - } } @@ -1639,8 +1638,6 @@ $sidebar-display: "sidebar-display"; $icon-block-size: 2rem; &.justify-content-center { - -webkit-box-pack: start !important; - -ms-flex-pack: start !important; justify-content: flex-start !important; } @@ -1665,6 +1662,7 @@ $sidebar-display: "sidebar-display"; position: absolute; top: 50%; left: 50%; + -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } } @@ -1672,9 +1670,6 @@ $sidebar-display: "sidebar-display"; .icon-border { top: 0.9rem; } - } /* .sidebar-bottom */ - } /* #sidebar */ - } /* min-width: 1650px */ diff --git a/_sass/addon/module.scss b/_sass/addon/module.scss index a07dc6e..9f1c986 100644 --- a/_sass/addon/module.scss +++ b/_sass/addon/module.scss @@ -7,7 +7,7 @@ %heading { color: var(--heading-color); font-weight: 400; - font-family: 'Lato', 'Microsoft Yahei', sans-serif; + font-family: Lato, "Microsoft Yahei", sans-serif; } %section { @@ -73,6 +73,8 @@ } %no-cursor { + -webkit-user-select: none; + -moz-user-select: none; user-select: none; } @@ -101,6 +103,8 @@ %sidebar-links { color: rgba(117, 117, 117, 0.9); + -webkit-user-select: none; + -moz-user-select: none; user-select: none; } @@ -134,7 +138,6 @@ position: relative; left: 50%; -webkit-transform: translateX(-50%); - -ms-transform: translateX(-50%); transform: translateX(-50%); } diff --git a/_sass/addon/syntax.scss b/_sass/addon/syntax.scss index cd861b3..361fe08 100644 --- a/_sass/addon/syntax.scss +++ b/_sass/addon/syntax.scss @@ -8,22 +8,22 @@ html { @media (prefers-color-scheme: light) { &:not([data-mode]), - &[data-mode=light] { + &[data-mode="light"] { @include light-syntax; } - &[data-mode=dark] { + &[data-mode="dark"] { @include dark-syntax; } } @media (prefers-color-scheme: dark) { &:not([data-mode]), - &[data-mode=dark] { + &[data-mode="dark"] { @include dark-syntax; } - &[data-mode=light] { + &[data-mode="light"] { @include light-syntax; } } @@ -87,24 +87,21 @@ $code-radius: 6px; text-align: right; color: var(--highlight-lineno-color); -webkit-user-select: none; - -khtml-user-select: none; -moz-user-select: none; - -ms-user-select: none; -o-user-select: none; user-select: none; } /* set the dollar sign to non-selectable */ .gp { + -webkit-user-select: none; + -moz-user-select: none; user-select: none; } - } /* .highlight */ code { -webkit-hyphens: none; - -ms-hyphens: none; - -moz-hyphens: none; hyphens: none; &.highlighter-rouge { @@ -152,16 +149,15 @@ td.rouge-code { border-bottom: none !important; pointer-events: none; } - } /* Hide line numbers for default, console, and terminal code snippets */ div { - &[class^='highlighter-rouge'], + &[class^="highlighter-rouge"], + &.nolineno, &.language-plaintext.highlighter-rouge, &.language-console.highlighter-rouge, - &.language-terminal.highlighter-rouge, - &.nolineno { + &.language-terminal.highlighter-rouge { pre.lineno { display: none; } @@ -252,6 +248,10 @@ div { } } + &:focus { + outline: none; + } + &:not([timeout]):hover { background-color: rgba(128, 128, 128, 0.37); @@ -259,18 +259,12 @@ div { color: white; } } - - &:focus { - outline: none; - } - } - } @media all and (max-width: 576px) { .post-content { - > div[class^='language-'] { + > div[class^="language-"] { @include ml-mr(-1.25rem); border-radius: 0; diff --git a/_sass/addon/variables.scss b/_sass/addon/variables.scss index 5e75f7f..99614a5 100644 --- a/_sass/addon/variables.scss +++ b/_sass/addon/variables.scss @@ -13,20 +13,16 @@ $sidebar-width-large: 350px !default; /* screen width: >= 1650px */ $tab-count: 5 !default; /* backward compatible (version <= 4.0.2) */ $tab-height: 3rem !default; $tab-cursor-height: 1.6rem !default; - $cursor-width: 2px !default; /* the cursor width of the selected tab */ /* other framework sizes */ $topbar-height: 3rem !default; - $search-max-width: 210px !default; - $footer-height: 5rem !default; $footer-height-mobile: 6rem !default; /* screen width: <= 576px */ $main-content-max-width: 1250px !default; - $bottom-min-height: 35rem !default; /* syntax highlight */ diff --git a/_sass/colors/dark-syntax.scss b/_sass/colors/dark-syntax.scss index 8030487..3912ed3 100644 --- a/_sass/colors/dark-syntax.scss +++ b/_sass/colors/dark-syntax.scss @@ -3,7 +3,24 @@ */ @mixin dark-syntax { + --highlight-bg-color: #252525; + --highlighter-rouge-color: #de6b18; + --highlight-lineno-color: #6c6c6d; + --inline-code-bg: #272822; + --code-header-text-color: #6a6a6a; + --code-header-muted-color: rgb(60, 60, 60); + --code-header-icon-color: rgb(86, 86, 86); + --clipboard-checked-color: #2bcc2b; + --filepath-text-color: #bdbdbd; + + pre { color: #bfbfbf; } /* override Bootstrap */ + + .highlight { + .gp { color: #818c96; } + } + /* syntax highlight colors from https://raw.githubusercontent.com/jwarby/pygments-css/master/monokai.css */ + .highlight pre { background-color: var(--highlight-bg-color); } .highlight .hll { background-color: var(--highlight-bg-color); } .highlight .c { color: #75715e; } /* Comment */ @@ -67,22 +84,4 @@ .highlight .gu { color: #75715e; } /* Generic.Subheading & Diff Unified/Comment? */ .highlight .gd { color: #f92672; background-color: #561c08; } /* Generic.Deleted & Diff Deleted */ .highlight .gi { color: #a6e22e; background-color: #0b5858; } /* Generic.Inserted & Diff Inserted */ - - /* ----- custom styles ------ */ - - --highlight-bg-color: #252525; - --highlighter-rouge-color: #de6b18; - --highlight-lineno-color: #6c6c6d; - --inline-code-bg: #272822; - --code-header-text-color: #6a6a6a; - --code-header-muted-color: rgb(60 60 60); - --code-header-icon-color: rgb(86 86 86); - --clipboard-checked-color: #2bcc2b; - --filepath-text-color: #bdbdbd; - - .highlight { - .gp { color: #818c96; } - } - - pre { color: #bfbfbf; } /* override Bootstrap */ } diff --git a/_sass/colors/dark-typography.scss b/_sass/colors/dark-typography.scss index e6fa40c..7b7a39f 100644 --- a/_sass/colors/dark-typography.scss +++ b/_sass/colors/dark-typography.scss @@ -4,9 +4,9 @@ @mixin dark-scheme { /* Framework color */ - --body-bg: var(--main-wrapper-bg); + --body-bg: var(--main-bg); --mask-bg: rgb(68, 69, 70); - --main-wrapper-bg: rgb(27, 27, 30); + --main-bg: rgb(27, 27, 30); --main-border-color: rgb(44, 45, 45); /* Common color */ @@ -21,18 +21,18 @@ --btn-border-color: rgb(63, 65, 68); --btn-backtotop-color: var(--text-color); --btn-backtotop-border-color: var(--btn-border-color); - --btn-box-shadow: var(--main-wrapper-bg); + --btn-box-shadow: var(--main-bg); --card-header-bg: rgb(51, 50, 50); --label-color: rgb(108, 117, 125); - --checkbox-color: rgb(118 120 121); + --checkbox-color: rgb(118, 120, 121); --checkbox-checked-color: var(--link-color); /* Sidebar */ --sidebar-bg: radial-gradient(circle, #242424 0%, #1d1f27 100%); --sidebar-muted-color: #6d6c6b; - --sidebar-active-color: rgb(255 255 255 / 80%); + --sidebar-active-color: rgb(255, 255, 255, 0.8); --nav-cursor-color: rgb(183, 182, 182); - --sidebar-btn-bg: rgb(117 116 116 / 20%); + --sidebar-btn-bg: rgb(117, 116, 116, 0.2); /* Topbar */ --topbar-text-color: var(--text-color); @@ -48,7 +48,7 @@ --btn-paginator-hover-color: rgb(64, 65, 66); --btn-paginator-border-color: var(--btn-border-color); --btn-text-color: var(--text-color); - --pin-bg: rgb(34 35 37); + --pin-bg: rgb(34, 35, 37); --pin-color: inherit; /* Posts */ @@ -64,19 +64,19 @@ --relate-post-date: var(--text-muted-color); --card-bg: rgb(39, 40, 43); --card-border-color: rgb(53, 53, 60); - --card-box-shadow: var(--main-wrapper-bg); - --preview-img-bg: radial-gradient(circle, rgb(22 22 24) 0%, rgb(32 32 32) 100%); + --card-box-shadow: var(--main-bg); + --preview-img-bg: radial-gradient(circle, rgb(22, 22, 24) 0%, rgb(32, 32, 32) 100%); --kbd-wrap-color: #6a6a6a; --kbd-text-color: #d3d3d3; --kbd-bg-color: #242424; - --prompt-text-color: rgb(216 212 212 / 75%); + --prompt-text-color: rgb(216, 212, 212, 0.75); --prompt-tip-bg: rgba(77, 187, 95, 0.2); - --prompt-tip-icon-color: rgb(5 223 5 / 68%); - --prompt-info-bg: rgb(7 59 104 / 80%); + --prompt-tip-icon-color: rgb(5, 223, 5, 0.68); + --prompt-info-bg: rgb(7, 59, 104, 0.8); --prompt-info-icon-color: #0075d1; - --prompt-warning-bg: rgb(90 69 3 / 95%); - --prompt-warning-icon-color: rgb(255 165 0 / 80%); - --prompt-danger-bg: rgb(86 28 8 / 80%); + --prompt-warning-bg: rgb(90, 69, 3, 0.95); + --prompt-warning-icon-color: rgb(255, 165, 0, 0.8); + --prompt-danger-bg: rgb(86, 28, 8, 0.8); --prompt-danger-icon-color: #cd0202; /* tags */ @@ -96,6 +96,7 @@ --timeline-year-dot-color: var(--timeline-color); .post img[data-src] { + -webkit-filter: brightness(95%); filter: brightness(95%); } @@ -104,11 +105,11 @@ } /* posts' toc, override BS */ - nav[data-toggle=toc] .nav-link.active, - nav[data-toggle=toc] .nav-link.active:focus, - nav[data-toggle=toc] .nav-link.active:hover, - nav[data-toggle=toc] .nav > li > a:focus, - nav[data-toggle=toc] .nav > li > a:hover { + nav[data-toggle="toc"] .nav-link.active, + nav[data-toggle="toc"] .nav-link.active:focus, + nav[data-toggle="toc"] .nav-link.active:hover, + nav[data-toggle="toc"] .nav > li > a:focus, + nav[data-toggle="toc"] .nav > li > a:hover { color: var(--toc-highlight) !important; border-left-color: var(--toc-highlight) !important; } @@ -150,8 +151,7 @@ color-scheme: dark; - #disqus_thread { + #disqus_thread { /* stylelint-disable-line selector-id-pattern */ color-scheme: none; } - } /* dark-scheme */ diff --git a/_sass/colors/light-syntax.scss b/_sass/colors/light-syntax.scss index 236e568..aeac91f 100644 --- a/_sass/colors/light-syntax.scss +++ b/_sass/colors/light-syntax.scss @@ -76,9 +76,8 @@ --code-header-icon-color: #d1d1d1; --clipboard-checked-color: #43c743; - [class^=prompt-] { + [class^="prompt-"] { --inline-code-bg: #fbfafa; - --highlighter-rouge-color: rgb(82 82 82); + --highlighter-rouge-color: rgb(82, 82, 82); } - } /* light-syntax */ diff --git a/_sass/colors/light-typography.scss b/_sass/colors/light-typography.scss index 122b38f..5e653f9 100644 --- a/_sass/colors/light-typography.scss +++ b/_sass/colors/light-typography.scss @@ -6,18 +6,18 @@ /* Framework color */ --body-bg: #fafafa; --mask-bg: #c1c3c5; - --main-wrapper-bg: white; + --main-bg: white; --main-border-color: #f3f3f3; /* Common color */ --text-color: #34343c; --text-muted-color: gray; --heading-color: black; - --blockquote-border-color: #eee; + --blockquote-border-color: #eeeeee; --blockquote-text-color: #9a9a9a; --link-color: #2a408e; --link-underline-color: #dee2e6; - --button-bg: #fff; + --button-bg: #ffffff; --btn-border-color: #e9ecef; --btn-backtotop-color: #686868; --btn-backtotop-border-color: #f1f1f1; @@ -35,8 +35,8 @@ /* Topbar */ --topbar-text-color: rgb(78, 78, 78); --topbar-wrapper-bg: white; - --search-wrapper-bg: rgb(245 245 245 / 50%); - --search-wrapper-border-color: rgb(245 245 245); + --search-wrapper-bg: rgb(245, 245, 245, 0.5); + --search-wrapper-border-color: rgb(245, 245, 245); --search-tag-bg: #f8f9fa; --search-icon-color: #c2c6cc; --input-focus-border-color: var(--btn-border-color); @@ -53,7 +53,7 @@ /* Posts */ --btn-share-hover-color: var(--link-color); --card-border-color: #f1f1f1; - --card-box-shadow: rgba(234, 234, 234, 0.7686274509803922); + --card-box-shadow: rgba(234, 234, 234, 0.76); --label-color: #616161; --relate-post-date: rgba(30, 55, 70, 0.4); --footnote-target-bg: lightcyan; @@ -64,22 +64,22 @@ --tb-odd-bg: #fbfcfd; --tb-border-color: #eaeaea; --dash-color: silver; - --preview-img-bg: radial-gradient(circle, rgb(255 255 255) 0%, rgb(249 249 249) 100%); + --preview-img-bg: radial-gradient(circle, rgb(255, 255, 255) 0%, rgb(249, 249, 249) 100%); --kbd-wrap-color: #bdbdbd; --kbd-text-color: var(--text-color); --kbd-bg-color: white; - --prompt-text-color: rgb(46 46 46 / 77%); - --prompt-tip-bg: rgb(123 247 144 / 20%); + --prompt-text-color: rgb(46, 46, 46, 0.77); + --prompt-tip-bg: rgb(123, 247, 144, 0.2); --prompt-tip-icon-color: #03b303; --prompt-info-bg: #e1f5fe; --prompt-info-icon-color: #0070cb; - --prompt-warning-bg: rgb(255 243 205); + --prompt-warning-bg: rgb(255, 243, 205); --prompt-warning-icon-color: #ef9c03; - --prompt-danger-bg: rgb(248 215 218 / 56%); + --prompt-danger-bg: rgb(248, 215, 218, 0.56); --prompt-danger-icon-color: #df3c30; - [class^=prompt-] { - --link-underline-color: rgb(219 216 216); + [class^="prompt-"] { + --link-underline-color: rgb(219, 216, 216); } /* Categories */ @@ -90,5 +90,4 @@ --timeline-color: rgba(0, 0, 0, 0.075); --timeline-node-bg: #c2c6cc; --timeline-year-dot-color: #ffffff; - } /* light-scheme */ diff --git a/_sass/jekyll-theme-chirpy.scss b/_sass/jekyll-theme-chirpy.scss index b15bcdc..2e04785 100644 --- a/_sass/jekyll-theme-chirpy.scss +++ b/_sass/jekyll-theme-chirpy.scss @@ -1,7 +1,7 @@ /*! * The styles for Jekyll theme Chirpy * - * Chirpy v5.3.0 (https://github.com/cotes2020/jekyll-theme-chirpy) + * Chirpy v5.3.1 (https://github.com/cotes2020/jekyll-theme-chirpy) * © 2019 Cotes Chung * MIT Licensed */ diff --git a/_sass/layout/archives.scss b/_sass/layout/archives.scss index 50d6dc7..70cf379 100644 --- a/_sass/layout/archives.scss +++ b/_sass/layout/archives.scss @@ -41,8 +41,6 @@ content: ""; display: inline-block; position: relative; - -webkit-border-radius: 50%; - -moz-border-radius: 50%; border-radius: 50%; width: 12px; height: 12px; @@ -53,7 +51,6 @@ box-shadow: 0 0 2px 0 #c2c6cc; z-index: 1; } - } ul { @@ -65,8 +62,8 @@ text-overflow: ellipsis; &:nth-child(odd) { - background-color: var(--main-wrapper-bg, #fff); - background-image: linear-gradient(to left, #fff, #fbfbfb, #fbfbfb, #fbfbfb, #fff); + background-color: var(--main-bg, #ffffff); + background-image: linear-gradient(to left, #ffffff, #fbfbfb, #fbfbfb, #fbfbfb, #ffffff); } &::before { @@ -81,7 +78,6 @@ &:last-child li:last-child::before { height: 1.5rem; } - } /* #archives ul */ .date { @@ -97,8 +93,7 @@ &.day { font-size: 85%; - font-family: 'Lato', sans-serif; - + font-family: Lato, sans-serif; } } @@ -117,8 +112,6 @@ content: ""; display: inline-block; position: relative; - -webkit-border-radius: 50%; - -moz-border-radius: 50%; border-radius: 50%; width: 8px; height: 8px; @@ -130,8 +123,7 @@ z-index: 1; } } - -} // #archives +} /* #archives */ @media all and (max-width: 576px) { #archives { diff --git a/_sass/layout/categories.scss b/_sass/layout/categories.scss index 29a3463..c818e33 100644 --- a/_sass/layout/categories.scss +++ b/_sass/layout/categories.scss @@ -16,7 +16,7 @@ i { @extend %category-icon-color; - font-size: 86%; // fontawesome icons + font-size: 86%; /* fontawesome icons */ } .list-group-item { @@ -28,10 +28,8 @@ border-top-left-radius: 0; border-top-right-radius: 0; } - } - -} // .categories +} /* .categories */ .category-trigger { width: 1.7rem; @@ -40,28 +38,29 @@ text-align: center; color: #6c757d !important; + i { + position: relative; + height: 0.7rem; + width: 1rem; + transition: -webkit-transform 300ms ease; + transition: transform 300ms ease; + transition: transform 300ms ease, -webkit-transform 300ms ease; + } + &:hover { i { color: var(--categories-icon-hover-color); } } - - i { - position: relative; - height: 0.7rem; - width: 1rem; - transition: transform 300ms ease; - } } -@media (hover: hover) { // only works on desktop +@media (hover: hover) { /* only works on desktop */ .category-trigger:hover { background-color: var(--categories-hover-bg); } } .rotate { - -ms-transform: rotate(-90deg); /* IE 9 */ - -webkit-transform: rotate(-90deg); /* Safari 3-8 */ + -webkit-transform: rotate(-90deg); transform: rotate(-90deg); } diff --git a/_sass/layout/category-tag.scss b/_sass/layout/category-tag.scss index e6d12d2..4488671 100644 --- a/_sass/layout/category-tag.scss +++ b/_sass/layout/category-tag.scss @@ -13,8 +13,8 @@ line-height: 1.5rem; padding: 0.6rem 0; - &::before { // dot - background: #999; + &::before { /* dot */ + background: #999999; width: 5px; height: 5px; border-radius: 50%; @@ -37,7 +37,7 @@ } } -#page-tag h1 > i { // tag icon +#page-tag h1 > i { /* tag icon */ font-size: 1.2rem; } @@ -51,7 +51,7 @@ a:hover { @extend %link-hover; - margin-bottom: -1px; // Avoid jumping + margin-bottom: -1px; /* Avoid jumping */ } } diff --git a/_sass/layout/home.scss b/_sass/layout/home.scss index 00a29d2..fd0f146 100644 --- a/_sass/layout/home.scss +++ b/_sass/layout/home.scss @@ -4,7 +4,7 @@ .pagination { color: var(--btn-patinator-text-color); - font-family: 'Lato', sans-serif; + font-family: Lato, sans-serif; a:hover { text-decoration: none; @@ -49,9 +49,8 @@ &:last-child .page-link { border-radius: 50%; } - } // .page-item - -} // .pagination + } /* .page-item */ +} /* .pagination */ #post-list { margin-top: 1rem; @@ -83,6 +82,19 @@ em { @extend %normal-font-style; } + + .pin { + i { + -webkit-transform: rotate(45deg); + transform: rotate(45deg); + padding-left: 3px; + color: var(--pin-color); + } + + span { + display: none; + } + } } .post-content { @@ -100,21 +112,8 @@ -webkit-box-orient: vertical; } } - - .pin { - > i { - transform: rotate(45deg); - padding-left: 3px; - color: var(--pin-color); - } - - > span { - display: none; - } - } - - } // .post-preview -} // #post-list + } /* .post-preview */ +} /* #post-list */ /* Hide SideBar and TOC */ @media all and (max-width: 830px) { @@ -125,9 +124,7 @@ &:not(:first-child):not(:last-child) { display: none; } - } - } } @@ -165,15 +162,12 @@ width: 2rem; height: 2rem; } - } .page-index { display: none; } - - } // .pagination - + } /* .pagination */ } /* Panel hidden */ diff --git a/_sass/layout/post.scss b/_sass/layout/post.scss index 79a15c4..5d9c0f9 100644 --- a/_sass/layout/post.scss +++ b/_sass/layout/post.scss @@ -26,6 +26,15 @@ color: var(--text-color); } +img.preview-img { + margin: 0; + border-radius: 6px; + + &.bg[data-loaded="true"] { + background: var(--preview-img-bg); + } +} + h1 + .post-meta { span + span::before { @include dot; @@ -40,23 +49,96 @@ h1 + .post-meta { } } -img.preview-img { - margin: 0; - border-radius: 6px; - - &.bg[data-loaded=true] { - background: var(--preview-img-bg); - } -} - .post-tail-wrapper { margin-top: 6rem; border-bottom: 1px double var(--main-border-color); font-size: 0.85rem; + .post-tail-bottom a { + color: inherit; + } + + .license-wrapper { + line-height: 1.2rem; + + > a { + color: var(--text-color); + + &:hover { + @extend %link-hover; + } + } + + span:last-child { + font-size: 0.85rem; + } + } /* .license-wrapper */ + .post-meta a:not(:hover) { @extend %link-underline; } + + .share-wrapper { + vertical-align: middle; + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + + .share-icons { + font-size: 1.2rem; + + > i { + position: relative; + bottom: 1px; + + @extend %cursor-pointer; + + &:hover { + @extend %btn-share-hovor; + } + } + + a { + &:not(:last-child) { + margin-right: 0.25rem; + } + + &:hover { + text-decoration: none; + + >i { + @extend %btn-share-hovor; + } + } + } + + .fab { + &.fa-twitter { + @include btn-sharing-color(rgba(29, 161, 242, 1)); + } + + &.fa-facebook-square { + @include btn-sharing-color(rgb(66, 95, 156)); + } + + &.fa-telegram { + @include btn-sharing-color(rgb(39, 159, 217)); + } + + &.fa-linkedin { + @include btn-sharing-color(rgb(0, 119, 181)); + } + + &.fa-weibo { + @include btn-sharing-color(rgb(229, 20, 43)); + } + } + } /* .share-icons */ + + .fas.fa-link { + @include btn-sharing-color(rgb(171, 171, 171)); + } + } /* .share-wrapper */ } .post-tags { @@ -74,7 +156,7 @@ img.preview-img { &:hover { background: #2a408e; - color: #fff; + color: #ffffff; border-color: #2a408e; } @@ -121,15 +203,29 @@ img.preview-img { margin-top: 0.3rem; white-space: normal; } - } /* .post-navigation */ +@-webkit-keyframes fade-up { + from { + opacity: 0; + position: relative; + top: 2rem; + } + + to { + opacity: 1; + position: relative; + top: 0; + } +} + @keyframes fade-up { from { opacity: 0; position: relative; top: 2rem; } + to { opacity: 1; position: relative; @@ -143,19 +239,23 @@ img.preview-img { position: sticky; top: 4rem; transition: top 0.2s ease-in-out; + -webkit-animation: fade-up 0.8s; animation: fade-up 0.8s; } -#toc li a { - font-size: 0.8rem; +#toc { + ul.nav.navbar-nav { + margin: 0.5rem 0; + padding: 0; - &.nav-link:not(.active) { - color: inherit; + li { + padding-top: 2px; + padding-bottom: 2px; + } } - } -nav[data-toggle=toc] { +nav[data-toggle="toc"] { .nav { .nav > li > a.active { font-weight: 600 !important; @@ -176,25 +276,6 @@ nav[data-toggle=toc] { color: var(--relate-post-date); } - .card { - border-color: var(--card-border-color); - background-color: var(--card-bg); - box-shadow: 0 0 5px 0 var(--card-box-shadow); - -webkit-transition: all 0.3s ease-in-out; - -moz-transition: all 0.3s ease-in-out; - transition: all 0.3s ease-in-out; - - h3 { - @extend %text-color; - } - - &:hover { - -webkit-transform: translate3d(0, -3px, 0); - transform: translate3d(0, -3px, 0); - box-shadow: 0 10px 15px -4px rgba(0, 0, 0, 0.15); - } - } - p { font-size: 0.9rem; margin-bottom: 0.5rem; @@ -209,20 +290,20 @@ nav[data-toggle=toc] { text-decoration: none; } - ul { - list-style-type: none; - padding-inline-start: 1.5rem; + .card { + border-color: var(--card-border-color); + background-color: var(--card-bg); + box-shadow: 0 0 5px 0 var(--card-box-shadow); + transition: all 0.3s ease-in-out; - > li::before { - background: #c2c9d4; - width: 5px; - height: 5px; - border-radius: 1px; - display: block; - content: ""; - position: relative; - top: 1rem; - right: 1rem; + h3 { + @extend %text-color; + } + + &:hover { + -webkit-transform: translate3d(0, -3px, 0); + transform: translate3d(0, -3px, 0); + box-shadow: 0 10px 15px -4px rgba(0, 0, 0, 0.15); } } } @@ -234,82 +315,15 @@ nav[data-toggle=toc] { margin-bottom: 2rem; } - #disqus_thread { + #disqus_thread { /* stylelint-disable-line selector-id-pattern */ min-height: 8.5rem; } - -} - -.post-tail-bottom a { - color: inherit; } %btn-share-hovor { color: var(--btn-share-hover-color) !important; } -.share-wrapper { - vertical-align: middle; - user-select: none; - - .share-icons { - font-size: 1.2rem; - - a { - &:not(:last-child) { - margin-right: 0.25rem; - } - - &:hover { - text-decoration: none; - - > i { - @extend %btn-share-hovor; - } - } - } - - > i { - position: relative; - bottom: 1px; - - @extend %cursor-pointer; - - &:hover { - @extend %btn-share-hovor; - } - } - - .fab { - &.fa-twitter { - @include btn-sharing-color(rgba(29, 161, 242, 1)); - } - - &.fa-facebook-square { - @include btn-sharing-color(rgb(66, 95, 156)); - } - - &.fa-telegram { - @include btn-sharing-color(rgb(39, 159, 217)); - } - - &.fa-linkedin { - @include btn-sharing-color(rgb(0, 119, 181)); - } - - &.fa-weibo { - @include btn-sharing-color(rgb(229, 20, 43)); - } - } - - } /* .share-icons */ - - .fas.fa-link { - @include btn-sharing-color(rgb(171, 171, 171)); - } - -} /* .share-wrapper */ - .share-label { @include label(inherit, 400, inherit); @@ -318,30 +332,12 @@ nav[data-toggle=toc] { } } -.license-wrapper { - line-height: 1.2rem; - - > a { - color: var(--text-color); - - &:hover { - @extend %link-hover; - } - } - - span:last-child { - font-size: 0.85rem; - } - -} /* .license-wrapper */ - @media all and (max-width: 576px) { .preview-img[data-src] { margin-top: 2.2rem; } .post-tail-bottom { - -ms-flex-wrap: wrap-reverse !important; flex-wrap: wrap-reverse !important; > div:first-child { diff --git a/_sass/layout/tags.scss b/_sass/layout/tags.scss index ab6c7b5..4cf5d3b 100644 --- a/_sass/layout/tags.scss +++ b/_sass/layout/tags.scss @@ -14,6 +14,6 @@ span { margin-left: 0.6em; font-size: 0.7em; - font-family: 'Oswald', sans-serif; + font-family: Oswald, sans-serif; } } diff --git a/_tabs/archives.md b/_tabs/archives.md index 1b42e95..c3abc59 100644 --- a/_tabs/archives.md +++ b/_tabs/archives.md @@ -3,4 +3,3 @@ layout: archives icon: fas fa-archive order: 3 --- - diff --git a/assets/404.html b/assets/404.html index 55f8f9d..4490ea5 100644 --- a/assets/404.html +++ b/assets/404.html @@ -9,8 +9,6 @@ redirect_from: - /posts/ --- -{% include lang.html %} - <div class="lead"> - <p>{{site.data.locales[lang].not_found.statment }}</p> + <p>{{site.data.locales[site.lang].not_found.statment }}</p> </div> diff --git a/assets/js/data/search.json b/assets/js/data/search.json index 5192c9f..1a766d9 100644 --- a/assets/js/data/search.json +++ b/assets/js/data/search.json @@ -12,7 +12,7 @@ swcache: true "tags": {{ post.tags | join: ', ' | jsonify }}, "date": "{{ post.date }}", {% include no-linenos.html content=post.content %} - "snippet": {{ content | strip_html | strip_newlines | jsonify }} + "snippet": {{ content | strip_html | strip_newlines | truncate: 200 | jsonify }} }{% unless forloop.last %},{% endunless %} {% endfor %} ] diff --git a/assets/js/data/swcache.js b/assets/js/data/swcache.js index b004d05..14a9f56 100644 --- a/assets/js/data/swcache.js +++ b/assets/js/data/swcache.js @@ -5,51 +5,50 @@ layout: compress --- const resource = [ + /* --- CSS --- */ + '{{ "/assets/css/style.css" | relative_url }}', - /* --- CSS --- */ - '{{ "/assets/css/style.css" | relative_url }}', + /* --- PWA --- */ + '{{ "/app.js" | relative_url }}', + '{{ "/sw.js" | relative_url }}', - /* --- PWA --- */ - '{{ "/app.js" | relative_url }}', - '{{ "/sw.js" | relative_url }}', + /* --- HTML --- */ + '{{ "/index.html" | relative_url }}', + '{{ "/404.html" | relative_url }}', - /* --- HTML --- */ - '{{ "/index.html" | relative_url }}', - '{{ "/404.html" | relative_url }}', - {% for tab in site.tabs %} - '{{ tab.url | relative_url }}', - {% endfor %} - - /* --- Favicons & compressed JS --- */ - {% assign cache_list = site.static_files | where: 'swcache', true %} - {% for file in cache_list %} - '{{ file.path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%} - {% endfor %} + {% for tab in site.tabs %} + '{{ tab.url | relative_url }}', + {% endfor %} + /* --- Favicons & compressed JS --- */ + {% assign cache_list = site.static_files | where: 'swcache', true %} + {% for file in cache_list %} + '{{ file.path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%} + {% endfor %} ]; /* The request url with below domain will be cached */ const allowedDomains = [ - {% if site.google_analytics.id != empty and site.google_analytics.id %} - 'www.googletagmanager.com', - 'www.google-analytics.com', - {% endif %} + {% if site.google_analytics.id != empty and site.google_analytics.id %} + 'www.googletagmanager.com', + 'www.google-analytics.com', + {% endif %} - '{{ site.url | split: "//" | last }}', + '{{ site.url | split: "//" | last }}', - {% if site.img_cdn contains '//' and site.img_cdn %} - '{{ site.img_cdn | split: '//' | last | split: '/' | first }}', - {% endif %} + {% if site.img_cdn contains '//' and site.img_cdn %} + '{{ site.img_cdn | split: '//' | last | split: '/' | first }}', + {% endif %} - 'fonts.gstatic.com', - 'fonts.googleapis.com', - 'cdn.jsdelivr.net', - 'polyfill.io' + 'fonts.gstatic.com', + 'fonts.googleapis.com', + 'cdn.jsdelivr.net', + 'polyfill.io' ]; /* Requests that include the following path will be banned */ const denyUrls = [ - {% if site.google_analytics.pv.cache_path %} - '{{ site.google_analytics.pv.cache_path | absolute_url }}' - {% endif %} + {% if site.google_analytics.pv.cache_path %} + '{{ site.google_analytics.pv.cache_path | absolute_url }}' + {% endif %} ]; diff --git a/assets/js/dist/categories.min.js b/assets/js/dist/categories.min.js index b882ccc..8001135 100644 --- a/assets/js/dist/categories.min.js +++ b/assets/js/dist/categories.min.js @@ -1,6 +1,6 @@ /*! - * Chirpy v5.3.0 (https://github.com/cotes2020/jekyll-theme-chirpy/) + * Chirpy v5.3.1 (https://github.com/cotes2020/jekyll-theme-chirpy/) * © 2019 Cotes Chung * MIT Licensed */ -$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(o=>{const e=$(o.target);let t=e.prop("tagName")==="button".toUpperCase()?e:e.parent();t.blur(),flipMode()})});const ScrollHelper=function(){const o=$("body"),e="data-topbar-visible",t=$("#topbar-wrapper").outerHeight();let l=0,a=!1,r=!1;return{hideTopbar:()=>o.attr(e,!1),showTopbar:()=>o.attr(e,!0),addScrollUpTask:()=>{l+=1,a=a||!0},popScrollUpTask:()=>--l,hasScrollUpTask:()=>0<l,topbarLocked:()=>!0===a,unlockTopbar:()=>a=!1,getTopbarHeight:()=>t,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}();$(function(){const o=$("#sidebar-trigger"),e=$("#search-trigger"),t=$("#search-cancel"),l=$("#main"),a=$("#topbar-title"),r=$("#search-wrapper"),n=$("#search-result-wrapper"),s=$("#search-results"),i=$("#search-input"),c=$("#search-hints"),d=function(){let o=0;return{block(){o=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(o)},getOffset(){return o}}}(),p={on(){o.addClass("unloaded"),a.addClass("unloaded"),e.addClass("unloaded"),r.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),r.removeClass("d-flex"),o.removeClass("unloaded"),a.removeClass("unloaded"),e.removeClass("unloaded")}},f=function(){let o=!1;return{on(){o||(d.block(),n.removeClass("unloaded"),l.addClass("unloaded"),o=!0)},off(){o&&(s.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),n.addClass("unloaded"),l.removeClass("unloaded"),d.release(),i.val(""),o=!1)},isVisible(){return o}}}();function u(){return t.hasClass("loaded")}e.click(function(){p.on(),f.on(),i.focus()}),t.click(function(){p.off(),f.off()}),i.focus(function(){r.addClass("input-focus")}),i.focusout(function(){r.removeClass("input-focus")}),i.on("input",()=>{""===i.val()?u()?c.removeClass("unloaded"):f.off():(f.on(),u()&&c.addClass("unloaded"))})}),$(function(){var o=function(){const o="sidebar-display";let e=!1;const t=$("body");return{toggle(){!1===e?t.attr(o,""):t.removeAttr(o),e=!e}}}();$("#sidebar-trigger").click(o.toggle),$("#mask").click(o.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#search-input"),t=ScrollHelper.getTopbarHeight();let o,l=0;function a(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var o=screen.orientation.type;"landscape-primary"!==o&&"landscape-secondary"!==o||a()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&a()}),$(window).scroll(()=>{o=o||!0}),setInterval(()=>{o&&(!function(){var o=$(this).scrollTop();if(!(Math.abs(l-o)<=t)){if(o>l)ScrollHelper.hideTopbar(),e.is(":focus")&&e.blur();else if(o+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}l=o}}(),o=!1)},250)}),$(function(){var e="div.post>h1:first-of-type";const t=$(e),n=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let l=t.text().trim(),a=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(l)&&(l=l.replace(/[0-9]/g,"").trim()),t.offset().top<$(window).scrollTop()&&n.text(l);let o=new IntersectionObserver(o=>{var e,t;a?(t=$(window).scrollTop(),e=r<t,r=t,t=o[0],e?0===t.intersectionRatio&&n.text(l):1===t.intersectionRatio&&n.text(s)):a=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});o.observe(document.querySelector(e)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(function(){const o=$(".collapse");o.on("hide.bs.collapse",function(){var o="h_"+$(this).attr("id").substring("l_".length);o&&($(`#${o} .far.fa-folder-open`).attr("class","far fa-folder fa-fw"),$(`#${o} i.fas`).addClass("rotate"),$("#"+o).removeClass("hide-border-bottom"))}),o.on("show.bs.collapse",function(){var o="h_"+$(this).attr("id").substring("l_".length);o&&($(`#${o} .far.fa-folder`).attr("class","far fa-folder-open fa-fw"),$(`#${o} i.fas`).removeClass("rotate"),$("#"+o).addClass("hide-border-bottom"))})}); \ No newline at end of file +$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(o=>{o=$(o.target);(o.prop("tagName")==="button".toUpperCase()?o:o.parent()).blur(),flipMode()})});const ScrollHelper=function(){const o=$("body"),e="data-topbar-visible",t=$("#topbar-wrapper").outerHeight();let a=0,r=!1,l=!1;return{hideTopbar:()=>o.attr(e,!1),showTopbar:()=>o.attr(e,!0),addScrollUpTask:()=>{a+=1,r=r||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0<a,topbarLocked:()=>!0===r,unlockTopbar:()=>r=!1,getTopbarHeight:()=>t,orientationLocked:()=>!0===l,lockOrientation:()=>l=!0,unLockOrientation:()=>l=!1}}();$(function(){const o=$("#sidebar-trigger"),e=$("#search-trigger"),t=$("#search-cancel"),a=$("#main"),r=$("#topbar-title"),l=$("#search-wrapper"),n=$("#search-result-wrapper"),s=$("#search-results"),i=$("#search-input"),c=$("#search-hints"),d=function(){let o=0;return{block(){o=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(o)},getOffset(){return o}}}(),p={on(){o.addClass("unloaded"),r.addClass("unloaded"),e.addClass("unloaded"),l.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),l.removeClass("d-flex"),o.removeClass("unloaded"),r.removeClass("unloaded"),e.removeClass("unloaded")}},f=function(){let o=!1;return{on(){o||(d.block(),n.removeClass("unloaded"),a.addClass("unloaded"),o=!0)},off(){o&&(s.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),n.addClass("unloaded"),a.removeClass("unloaded"),d.release(),i.val(""),o=!1)},isVisible(){return o}}}();function u(){return t.hasClass("loaded")}e.click(function(){p.on(),f.on(),i.focus()}),t.click(function(){p.off(),f.off()}),i.focus(function(){l.addClass("input-focus")}),i.focusout(function(){l.removeClass("input-focus")}),i.on("input",()=>{""===i.val()?u()?c.removeClass("unloaded"):f.off():(f.on(),u()&&c.addClass("unloaded"))})}),$(function(){var o=function(){const o="sidebar-display";let e=!1;const t=$("body");return{toggle(){!1===e?t.attr(o,""):t.removeAttr(o),e=!e}}}();$("#sidebar-trigger").click(o.toggle),$("#mask").click(o.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#search-input"),t=ScrollHelper.getTopbarHeight();let o,a=0;function r(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var o=screen.orientation.type;"landscape-primary"!==o&&"landscape-secondary"!==o||r()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&r()}),$(window).scroll(()=>{o=o||!0}),setInterval(()=>{o&&(!function(){var o=$(this).scrollTop();if(!(Math.abs(a-o)<=t)){if(o>a)ScrollHelper.hideTopbar(),e.is(":focus")&&e.blur();else if(o+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=o}}(),o=!1)},250)}),$(function(){var o="div.post>h1:first-of-type",e=$(o);const n=$("#topbar-title");if(0!==e.length&&!e.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let a=e.text().trim(),r=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),e.offset().top<$(window).scrollTop()&&n.text(a);new IntersectionObserver(o=>{var e,t;r?(t=$(window).scrollTop(),e=l<t,l=t,t=o[0],e?0===t.intersectionRatio&&n.text(a):1===t.intersectionRatio&&n.text(s)):r=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]}).observe(document.querySelector(o)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(function(){var o=$(".collapse");o.on("hide.bs.collapse",function(){var o="h_"+$(this).attr("id").substring("l_".length);o&&($(`#${o} .far.fa-folder-open`).attr("class","far fa-folder fa-fw"),$(`#${o} i.fas`).addClass("rotate"),$("#"+o).removeClass("hide-border-bottom"))}),o.on("show.bs.collapse",function(){var o="h_"+$(this).attr("id").substring("l_".length);o&&($(`#${o} .far.fa-folder`).attr("class","far fa-folder-open fa-fw"),$(`#${o} i.fas`).removeClass("rotate"),$("#"+o).addClass("hide-border-bottom"))})}); diff --git a/assets/js/dist/commons.min.js b/assets/js/dist/commons.min.js index 4020b08..1bd2d6a 100644 --- a/assets/js/dist/commons.min.js +++ b/assets/js/dist/commons.min.js @@ -1,6 +1,6 @@ /*! - * Chirpy v5.3.0 (https://github.com/cotes2020/jekyll-theme-chirpy/) + * Chirpy v5.3.1 (https://github.com/cotes2020/jekyll-theme-chirpy/) * © 2019 Cotes Chung * MIT Licensed */ -$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(o=>{const e=$(o.target);let t=e.prop("tagName")==="button".toUpperCase()?e:e.parent();t.blur(),flipMode()})});const ScrollHelper=function(){const o=$("body"),e="data-topbar-visible",t=$("#topbar-wrapper").outerHeight();let l=0,r=!1,a=!1;return{hideTopbar:()=>o.attr(e,!1),showTopbar:()=>o.attr(e,!0),addScrollUpTask:()=>{l+=1,r=r||!0},popScrollUpTask:()=>--l,hasScrollUpTask:()=>0<l,topbarLocked:()=>!0===r,unlockTopbar:()=>r=!1,getTopbarHeight:()=>t,orientationLocked:()=>!0===a,lockOrientation:()=>a=!0,unLockOrientation:()=>a=!1}}();$(function(){const o=$("#sidebar-trigger"),e=$("#search-trigger"),t=$("#search-cancel"),l=$("#main"),r=$("#topbar-title"),a=$("#search-wrapper"),n=$("#search-result-wrapper"),s=$("#search-results"),i=$("#search-input"),c=$("#search-hints"),d=function(){let o=0;return{block(){o=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(o)},getOffset(){return o}}}(),p={on(){o.addClass("unloaded"),r.addClass("unloaded"),e.addClass("unloaded"),a.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),a.removeClass("d-flex"),o.removeClass("unloaded"),r.removeClass("unloaded"),e.removeClass("unloaded")}},u=function(){let o=!1;return{on(){o||(d.block(),n.removeClass("unloaded"),l.addClass("unloaded"),o=!0)},off(){o&&(s.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),n.addClass("unloaded"),l.removeClass("unloaded"),d.release(),i.val(""),o=!1)},isVisible(){return o}}}();function f(){return t.hasClass("loaded")}e.click(function(){p.on(),u.on(),i.focus()}),t.click(function(){p.off(),u.off()}),i.focus(function(){a.addClass("input-focus")}),i.focusout(function(){a.removeClass("input-focus")}),i.on("input",()=>{""===i.val()?f()?c.removeClass("unloaded"):u.off():(u.on(),f()&&c.addClass("unloaded"))})}),$(function(){var o=function(){const o="sidebar-display";let e=!1;const t=$("body");return{toggle(){!1===e?t.attr(o,""):t.removeAttr(o),e=!e}}}();$("#sidebar-trigger").click(o.toggle),$("#mask").click(o.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#search-input"),t=ScrollHelper.getTopbarHeight();let o,l=0;function r(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var o=screen.orientation.type;"landscape-primary"!==o&&"landscape-secondary"!==o||r()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&r()}),$(window).scroll(()=>{o=o||!0}),setInterval(()=>{o&&(!function(){var o=$(this).scrollTop();if(!(Math.abs(l-o)<=t)){if(o>l)ScrollHelper.hideTopbar(),e.is(":focus")&&e.blur();else if(o+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}l=o}}(),o=!1)},250)}),$(function(){var e="div.post>h1:first-of-type";const t=$(e),n=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let l=t.text().trim(),r=!1,a=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(l)&&(l=l.replace(/[0-9]/g,"").trim()),t.offset().top<$(window).scrollTop()&&n.text(l);let o=new IntersectionObserver(o=>{var e,t;r?(t=$(window).scrollTop(),e=a<t,a=t,t=o[0],e?0===t.intersectionRatio&&n.text(l):1===t.intersectionRatio&&n.text(s)):r=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});o.observe(document.querySelector(e)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}); \ No newline at end of file +$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(o=>{o=$(o.target);(o.prop("tagName")==="button".toUpperCase()?o:o.parent()).blur(),flipMode()})});const ScrollHelper=function(){const o=$("body"),e="data-topbar-visible",t=$("#topbar-wrapper").outerHeight();let l=0,r=!1,a=!1;return{hideTopbar:()=>o.attr(e,!1),showTopbar:()=>o.attr(e,!0),addScrollUpTask:()=>{l+=1,r=r||!0},popScrollUpTask:()=>--l,hasScrollUpTask:()=>0<l,topbarLocked:()=>!0===r,unlockTopbar:()=>r=!1,getTopbarHeight:()=>t,orientationLocked:()=>!0===a,lockOrientation:()=>a=!0,unLockOrientation:()=>a=!1}}();$(function(){const o=$("#sidebar-trigger"),e=$("#search-trigger"),t=$("#search-cancel"),l=$("#main"),r=$("#topbar-title"),a=$("#search-wrapper"),n=$("#search-result-wrapper"),s=$("#search-results"),i=$("#search-input"),c=$("#search-hints"),d=function(){let o=0;return{block(){o=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(o)},getOffset(){return o}}}(),p={on(){o.addClass("unloaded"),r.addClass("unloaded"),e.addClass("unloaded"),a.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),a.removeClass("d-flex"),o.removeClass("unloaded"),r.removeClass("unloaded"),e.removeClass("unloaded")}},u=function(){let o=!1;return{on(){o||(d.block(),n.removeClass("unloaded"),l.addClass("unloaded"),o=!0)},off(){o&&(s.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),n.addClass("unloaded"),l.removeClass("unloaded"),d.release(),i.val(""),o=!1)},isVisible(){return o}}}();function f(){return t.hasClass("loaded")}e.click(function(){p.on(),u.on(),i.focus()}),t.click(function(){p.off(),u.off()}),i.focus(function(){a.addClass("input-focus")}),i.focusout(function(){a.removeClass("input-focus")}),i.on("input",()=>{""===i.val()?f()?c.removeClass("unloaded"):u.off():(u.on(),f()&&c.addClass("unloaded"))})}),$(function(){var o=function(){const o="sidebar-display";let e=!1;const t=$("body");return{toggle(){!1===e?t.attr(o,""):t.removeAttr(o),e=!e}}}();$("#sidebar-trigger").click(o.toggle),$("#mask").click(o.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#search-input"),t=ScrollHelper.getTopbarHeight();let o,l=0;function r(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var o=screen.orientation.type;"landscape-primary"!==o&&"landscape-secondary"!==o||r()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&r()}),$(window).scroll(()=>{o=o||!0}),setInterval(()=>{o&&(!function(){var o=$(this).scrollTop();if(!(Math.abs(l-o)<=t)){if(o>l)ScrollHelper.hideTopbar(),e.is(":focus")&&e.blur();else if(o+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}l=o}}(),o=!1)},250)}),$(function(){var o="div.post>h1:first-of-type",e=$(o);const n=$("#topbar-title");if(0!==e.length&&!e.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let l=e.text().trim(),r=!1,a=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(l)&&(l=l.replace(/[0-9]/g,"").trim()),e.offset().top<$(window).scrollTop()&&n.text(l);new IntersectionObserver(o=>{var e,t;r?(t=$(window).scrollTop(),e=a<t,a=t,t=o[0],e?0===t.intersectionRatio&&n.text(l):1===t.intersectionRatio&&n.text(s)):r=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]}).observe(document.querySelector(o)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}); diff --git a/assets/js/dist/home.min.js b/assets/js/dist/home.min.js index 03e9f4d..c9c6649 100644 --- a/assets/js/dist/home.min.js +++ b/assets/js/dist/home.min.js @@ -1,6 +1,6 @@ /*! - * Chirpy v5.3.0 (https://github.com/cotes2020/jekyll-theme-chirpy/) + * Chirpy v5.3.1 (https://github.com/cotes2020/jekyll-theme-chirpy/) * © 2019 Cotes Chung * MIT Licensed */ -$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(e=>{const t=$(e.target);let o=t.prop("tagName")==="button".toUpperCase()?t:t.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,l=!1,r=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{a+=1,l=l||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0<a,topbarLocked:()=>!0===l,unlockTopbar:()=>l=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}(),LocaleHelper=($(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),a=$("#main"),l=$("#topbar-title"),r=$("#search-wrapper"),n=$("#search-result-wrapper"),s=$("#search-results"),i=$("#search-input"),c=$("#search-hints"),d=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),p={on(){e.addClass("unloaded"),l.addClass("unloaded"),t.addClass("unloaded"),r.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),r.removeClass("d-flex"),e.removeClass("unloaded"),l.removeClass("unloaded"),t.removeClass("unloaded")}},u=function(){let e=!1;return{on(){e||(d.block(),n.removeClass("unloaded"),a.addClass("unloaded"),e=!0)},off(){e&&(s.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),n.addClass("unloaded"),a.removeClass("unloaded"),d.release(),i.val(""),e=!1)},isVisible(){return e}}}();function f(){return o.hasClass("loaded")}t.click(function(){p.on(),u.on(),i.focus()}),o.click(function(){p.off(),u.off()}),i.focus(function(){r.addClass("input-focus")}),i.focusout(function(){r.removeClass("input-focus")}),i.on("input",()=>{""===i.val()?f()?c.removeClass("unloaded"):u.off():(u.on(),f()&&c.addClass("unloaded"))})}),$(function(){var e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,a=0;function l(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||l()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&l()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(!function(){var e=$(this).scrollTop();if(!(Math.abs(a-e)<=o)){if(e>a)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=e}}(),e=!1)},250)}),$(function(){var t="div.post>h1:first-of-type";const o=$(t),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let a=o.text().trim(),l=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(a);let e=new IntersectionObserver(e=>{var t,o;l?(o=$(window).scrollTop(),t=r<o,r=o,o=e[0],t?0===o.intersectionRatio&&n.text(a):1===o.intersectionRatio&&n.text(s)):l=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});e.observe(document.querySelector(t)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),function(){const e=$('meta[name="prefer-datetime-locale"]'),t=0<e.length?e.attr("content").toLowerCase():$("html").attr("lang").substr(0,2),o="data-ts",a="data-df";return{locale:()=>t,attrTimestamp:()=>o,attrDateFormat:()=>a,getTimestamp:e=>Number(e.attr(o)),getDateFormat:e=>e.attr(a)}}());$(function(){dayjs.locale(LocaleHelper.locale()),dayjs.extend(window.dayjs_plugin_localizedFormat),$(`[${LocaleHelper.attrTimestamp()}]`).each(function(){const e=dayjs.unix(LocaleHelper.getTimestamp($(this)));var t=e.format(LocaleHelper.getDateFormat($(this))),t=($(this).text(t),$(this).removeAttr(LocaleHelper.attrTimestamp()),$(this).removeAttr(LocaleHelper.attrDateFormat()),$(this).attr("data-toggle"));void 0!==t&&"tooltip"===t&&(t=e.format("llll"),$(this).attr("data-original-title",t))})}); \ No newline at end of file +$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(e=>{e=$(e.target);(e.prop("tagName")==="button".toUpperCase()?e:e.parent()).blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,l=!1,r=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{a+=1,l=l||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0<a,topbarLocked:()=>!0===l,unlockTopbar:()=>l=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}(),LocaleHelper=($(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),a=$("#main"),l=$("#topbar-title"),r=$("#search-wrapper"),n=$("#search-result-wrapper"),s=$("#search-results"),i=$("#search-input"),c=$("#search-hints"),d=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),p={on(){e.addClass("unloaded"),l.addClass("unloaded"),t.addClass("unloaded"),r.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),r.removeClass("d-flex"),e.removeClass("unloaded"),l.removeClass("unloaded"),t.removeClass("unloaded")}},u=function(){let e=!1;return{on(){e||(d.block(),n.removeClass("unloaded"),a.addClass("unloaded"),e=!0)},off(){e&&(s.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),n.addClass("unloaded"),a.removeClass("unloaded"),d.release(),i.val(""),e=!1)},isVisible(){return e}}}();function f(){return o.hasClass("loaded")}t.click(function(){p.on(),u.on(),i.focus()}),o.click(function(){p.off(),u.off()}),i.focus(function(){r.addClass("input-focus")}),i.focusout(function(){r.removeClass("input-focus")}),i.on("input",()=>{""===i.val()?f()?c.removeClass("unloaded"):u.off():(u.on(),f()&&c.addClass("unloaded"))})}),$(function(){var e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,a=0;function l(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||l()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&l()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(!function(){var e=$(this).scrollTop();if(!(Math.abs(a-e)<=o)){if(e>a)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=e}}(),e=!1)},250)}),$(function(){var e="div.post>h1:first-of-type",t=$(e);const n=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let a=t.text().trim(),l=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),t.offset().top<$(window).scrollTop()&&n.text(a);new IntersectionObserver(e=>{var t,o;l?(o=$(window).scrollTop(),t=r<o,r=o,o=e[0],t?0===o.intersectionRatio&&n.text(a):1===o.intersectionRatio&&n.text(s)):l=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]}).observe(document.querySelector(e)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),function(){const e=$("html").attr("lang").substr(0,2),t="data-ts",o="data-df";return{locale:()=>e,attrTimestamp:()=>t,attrDateFormat:()=>o,getTimestamp:e=>Number(e.attr(t)),getDateFormat:e=>e.attr(o)}}());$(function(){dayjs.locale(LocaleHelper.locale()),dayjs.extend(window.dayjs_plugin_localizedFormat),$(`[${LocaleHelper.attrTimestamp()}]`).each(function(){var e=dayjs.unix(LocaleHelper.getTimestamp($(this))),t=e.format(LocaleHelper.getDateFormat($(this))),t=($(this).text(t),$(this).removeAttr(LocaleHelper.attrTimestamp()),$(this).removeAttr(LocaleHelper.attrDateFormat()),$(this).attr("data-toggle"));void 0!==t&&"tooltip"===t&&(t=e.format("llll"),$(this).attr("data-original-title",t))})}); diff --git a/assets/js/dist/misc.min.js b/assets/js/dist/misc.min.js index 03e9f4d..c9c6649 100644 --- a/assets/js/dist/misc.min.js +++ b/assets/js/dist/misc.min.js @@ -1,6 +1,6 @@ /*! - * Chirpy v5.3.0 (https://github.com/cotes2020/jekyll-theme-chirpy/) + * Chirpy v5.3.1 (https://github.com/cotes2020/jekyll-theme-chirpy/) * © 2019 Cotes Chung * MIT Licensed */ -$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(e=>{const t=$(e.target);let o=t.prop("tagName")==="button".toUpperCase()?t:t.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,l=!1,r=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{a+=1,l=l||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0<a,topbarLocked:()=>!0===l,unlockTopbar:()=>l=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}(),LocaleHelper=($(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),a=$("#main"),l=$("#topbar-title"),r=$("#search-wrapper"),n=$("#search-result-wrapper"),s=$("#search-results"),i=$("#search-input"),c=$("#search-hints"),d=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),p={on(){e.addClass("unloaded"),l.addClass("unloaded"),t.addClass("unloaded"),r.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),r.removeClass("d-flex"),e.removeClass("unloaded"),l.removeClass("unloaded"),t.removeClass("unloaded")}},u=function(){let e=!1;return{on(){e||(d.block(),n.removeClass("unloaded"),a.addClass("unloaded"),e=!0)},off(){e&&(s.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),n.addClass("unloaded"),a.removeClass("unloaded"),d.release(),i.val(""),e=!1)},isVisible(){return e}}}();function f(){return o.hasClass("loaded")}t.click(function(){p.on(),u.on(),i.focus()}),o.click(function(){p.off(),u.off()}),i.focus(function(){r.addClass("input-focus")}),i.focusout(function(){r.removeClass("input-focus")}),i.on("input",()=>{""===i.val()?f()?c.removeClass("unloaded"):u.off():(u.on(),f()&&c.addClass("unloaded"))})}),$(function(){var e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,a=0;function l(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||l()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&l()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(!function(){var e=$(this).scrollTop();if(!(Math.abs(a-e)<=o)){if(e>a)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=e}}(),e=!1)},250)}),$(function(){var t="div.post>h1:first-of-type";const o=$(t),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let a=o.text().trim(),l=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(a);let e=new IntersectionObserver(e=>{var t,o;l?(o=$(window).scrollTop(),t=r<o,r=o,o=e[0],t?0===o.intersectionRatio&&n.text(a):1===o.intersectionRatio&&n.text(s)):l=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});e.observe(document.querySelector(t)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),function(){const e=$('meta[name="prefer-datetime-locale"]'),t=0<e.length?e.attr("content").toLowerCase():$("html").attr("lang").substr(0,2),o="data-ts",a="data-df";return{locale:()=>t,attrTimestamp:()=>o,attrDateFormat:()=>a,getTimestamp:e=>Number(e.attr(o)),getDateFormat:e=>e.attr(a)}}());$(function(){dayjs.locale(LocaleHelper.locale()),dayjs.extend(window.dayjs_plugin_localizedFormat),$(`[${LocaleHelper.attrTimestamp()}]`).each(function(){const e=dayjs.unix(LocaleHelper.getTimestamp($(this)));var t=e.format(LocaleHelper.getDateFormat($(this))),t=($(this).text(t),$(this).removeAttr(LocaleHelper.attrTimestamp()),$(this).removeAttr(LocaleHelper.attrDateFormat()),$(this).attr("data-toggle"));void 0!==t&&"tooltip"===t&&(t=e.format("llll"),$(this).attr("data-original-title",t))})}); \ No newline at end of file +$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(e=>{e=$(e.target);(e.prop("tagName")==="button".toUpperCase()?e:e.parent()).blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,l=!1,r=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{a+=1,l=l||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0<a,topbarLocked:()=>!0===l,unlockTopbar:()=>l=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}(),LocaleHelper=($(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),a=$("#main"),l=$("#topbar-title"),r=$("#search-wrapper"),n=$("#search-result-wrapper"),s=$("#search-results"),i=$("#search-input"),c=$("#search-hints"),d=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),p={on(){e.addClass("unloaded"),l.addClass("unloaded"),t.addClass("unloaded"),r.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),r.removeClass("d-flex"),e.removeClass("unloaded"),l.removeClass("unloaded"),t.removeClass("unloaded")}},u=function(){let e=!1;return{on(){e||(d.block(),n.removeClass("unloaded"),a.addClass("unloaded"),e=!0)},off(){e&&(s.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),n.addClass("unloaded"),a.removeClass("unloaded"),d.release(),i.val(""),e=!1)},isVisible(){return e}}}();function f(){return o.hasClass("loaded")}t.click(function(){p.on(),u.on(),i.focus()}),o.click(function(){p.off(),u.off()}),i.focus(function(){r.addClass("input-focus")}),i.focusout(function(){r.removeClass("input-focus")}),i.on("input",()=>{""===i.val()?f()?c.removeClass("unloaded"):u.off():(u.on(),f()&&c.addClass("unloaded"))})}),$(function(){var e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,a=0;function l(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||l()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&l()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(!function(){var e=$(this).scrollTop();if(!(Math.abs(a-e)<=o)){if(e>a)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=e}}(),e=!1)},250)}),$(function(){var e="div.post>h1:first-of-type",t=$(e);const n=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let a=t.text().trim(),l=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),t.offset().top<$(window).scrollTop()&&n.text(a);new IntersectionObserver(e=>{var t,o;l?(o=$(window).scrollTop(),t=r<o,r=o,o=e[0],t?0===o.intersectionRatio&&n.text(a):1===o.intersectionRatio&&n.text(s)):l=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]}).observe(document.querySelector(e)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),function(){const e=$("html").attr("lang").substr(0,2),t="data-ts",o="data-df";return{locale:()=>e,attrTimestamp:()=>t,attrDateFormat:()=>o,getTimestamp:e=>Number(e.attr(t)),getDateFormat:e=>e.attr(o)}}());$(function(){dayjs.locale(LocaleHelper.locale()),dayjs.extend(window.dayjs_plugin_localizedFormat),$(`[${LocaleHelper.attrTimestamp()}]`).each(function(){var e=dayjs.unix(LocaleHelper.getTimestamp($(this))),t=e.format(LocaleHelper.getDateFormat($(this))),t=($(this).text(t),$(this).removeAttr(LocaleHelper.attrTimestamp()),$(this).removeAttr(LocaleHelper.attrDateFormat()),$(this).attr("data-toggle"));void 0!==t&&"tooltip"===t&&(t=e.format("llll"),$(this).attr("data-original-title",t))})}); diff --git a/assets/js/dist/page.min.js b/assets/js/dist/page.min.js index adacd4a..b17eb2a 100644 --- a/assets/js/dist/page.min.js +++ b/assets/js/dist/page.min.js @@ -1,6 +1,6 @@ /*! - * Chirpy v5.3.0 (https://github.com/cotes2020/jekyll-theme-chirpy/) + * Chirpy v5.3.1 (https://github.com/cotes2020/jekyll-theme-chirpy/) * © 2019 Cotes Chung * MIT Licensed */ -$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(e=>{const t=$(e.target);let o=t.prop("tagName")==="button".toUpperCase()?t:t.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let r=0,a=!1,l=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{r+=1,a=a||!0},popScrollUpTask:()=>--r,hasScrollUpTask:()=>0<r,topbarLocked:()=>!0===a,unlockTopbar:()=>a=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===l,lockOrientation:()=>l=!0,unLockOrientation:()=>l=!1}}();$(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),r=$("#main"),a=$("#topbar-title"),l=$("#search-wrapper"),n=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),s=$("#search-hints"),d=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),p={on(){e.addClass("unloaded"),a.addClass("unloaded"),t.addClass("unloaded"),l.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),l.removeClass("d-flex"),e.removeClass("unloaded"),a.removeClass("unloaded"),t.removeClass("unloaded")}},u=function(){let e=!1;return{on(){e||(d.block(),n.removeClass("unloaded"),r.addClass("unloaded"),e=!0)},off(){e&&(i.empty(),s.hasClass("unloaded")&&s.removeClass("unloaded"),n.addClass("unloaded"),r.removeClass("unloaded"),d.release(),c.val(""),e=!1)},isVisible(){return e}}}();function h(){return o.hasClass("loaded")}t.click(function(){p.on(),u.on(),c.focus()}),o.click(function(){p.off(),u.off()}),c.focus(function(){l.addClass("input-focus")}),c.focusout(function(){l.removeClass("input-focus")}),c.on("input",()=>{""===c.val()?h()?s.removeClass("unloaded"):u.off():(u.on(),h()&&s.addClass("unloaded"))})}),$(function(){var e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,r=0;function a(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||a()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&a()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(!function(){var e=$(this).scrollTop();if(!(Math.abs(r-e)<=o)){if(e>r)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}r=e}}(),e=!1)},250)}),$(function(){var t="div.post>h1:first-of-type";const o=$(t),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const i=n.text().trim();let r=o.text().trim(),a=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(r)&&(r=r.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(r);let e=new IntersectionObserver(e=>{var t,o;a?(o=$(window).scrollTop(),t=l<o,l=o,o=e[0],t?0===o.intersectionRatio&&n.text(r):1===o.intersectionRatio&&n.text(i)):a=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});e.observe(document.querySelector(t)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(function(){$("input[type=checkbox]").addClass("unloaded"),$("input[type=checkbox][checked]").before('<i class="fas fa-check-circle checked"></i>'),$("input[type=checkbox]:not([checked])").before('<i class="far fa-circle"></i>')}),$(function(){var e="#main > div.row:first-child > div:first-child";if(!($(e+" img").length<=0)){var t=document.querySelectorAll(e+" img[data-src]");const o=lozad(t);o.observe(),$(e+` p > img[data-src],${e} img[data-src].preview-img`).each(function(){let e=$(this).next();var t="EM"===e.prop("tagName")?e.text():"",o=$(this).attr("data-src");$(this).wrap(`<a href="${o}" title="${t}" class="popup"></a>`)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(e+" a").has("img").addClass("img-link")}}),$(function(){var e=".code-header>button";const t="timeout",a="data-title-succeed",l="data-original-title";function n(e){if($(e)[0].hasAttribute(t)){e=$(e).attr(t);if(Number(e)>Date.now())return 1}}function i(e){$(e).attr(t,Date.now()+2e3)}function c(e){$(e).removeAttr(t)}const o=new ClipboardJS(e,{target(e){let t=e.parentNode.nextElementSibling;return t.querySelector("code .rouge-code")}});$(e).tooltip({trigger:"hover",placement:"left"});const s=function(e){let t=$(e).children();return t.attr("class")}(e);o.on("success",o=>{o.clearSelection();const r=o.trigger;if(!n(r)){{o=r;let e=$(o),t=e.children();t.attr("class","fas fa-check")}var e;o=r,e=$(o).attr(a),$(o).attr(l,e).tooltip("show"),i(r),setTimeout(()=>{o=r,$(o).tooltip("hide").removeAttr(l);{var o=r;let e=$(o),t=e.children();t.attr("class",s)}c(r)},2e3)}}),$("#copy-link").click(e=>{let t=$(e.target);if(!n(t)){e=window.location.href;const o=$("<input>"),r=($("body").append(o),o.val(e).select(),document.execCommand("copy"),o.remove(),t.attr(l));e=t.attr(a);t.attr(l,e).tooltip("show"),i(t),setTimeout(()=>{t.attr(l,r),c(t)},2e3)}})}),$(function(){const e=$("#topbar-title"),c="scroll-focus";$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(a){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const i=decodeURI(this.hash);let t=RegExp(/^#fnref:/).test(i),o=!t&&RegExp(/^#fn:/).test(i);var l=i.includes(":")?i.replace(/\:/g,"\\:"):i;let r=$(l);var l=e.is(":visible"),n=$(window).width()<$(window).height();if(void 0!==r){a.preventDefault(),history.pushState&&history.pushState(null,null,i);a=$(window).scrollTop();let e=r.offset().top-=8;e<a&&(ScrollHelper.hideTopbar(),ScrollHelper.addScrollUpTask()),l&&n&&(e-=ScrollHelper.getTopbarHeight()),$("html").animate({scrollTop:e},500,()=>{if(r.focus(),$(`[${c}=true]`).length&&$(`[${c}=true]`).attr(c,!1),$(":target").length&&$(":target").attr(c,!1),(o||t)&&r.attr(c,!0),r.is(":focus"))return!1;r.attr("tabindex","-1"),r.focus(),ScrollHelper.hasScrollUpTask()&&ScrollHelper.popScrollUpTask()})}}})}); \ No newline at end of file +$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(e=>{e=$(e.target);(e.prop("tagName")==="button".toUpperCase()?e:e.parent()).blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let r=0,a=!1,l=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{r+=1,a=a||!0},popScrollUpTask:()=>--r,hasScrollUpTask:()=>0<r,topbarLocked:()=>!0===a,unlockTopbar:()=>a=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===l,lockOrientation:()=>l=!0,unLockOrientation:()=>l=!1}}();$(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),r=$("#main"),a=$("#topbar-title"),l=$("#search-wrapper"),n=$("#search-result-wrapper"),i=$("#search-results"),s=$("#search-input"),c=$("#search-hints"),d=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),p={on(){e.addClass("unloaded"),a.addClass("unloaded"),t.addClass("unloaded"),l.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),l.removeClass("d-flex"),e.removeClass("unloaded"),a.removeClass("unloaded"),t.removeClass("unloaded")}},u=function(){let e=!1;return{on(){e||(d.block(),n.removeClass("unloaded"),r.addClass("unloaded"),e=!0)},off(){e&&(i.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),n.addClass("unloaded"),r.removeClass("unloaded"),d.release(),s.val(""),e=!1)},isVisible(){return e}}}();function h(){return o.hasClass("loaded")}t.click(function(){p.on(),u.on(),s.focus()}),o.click(function(){p.off(),u.off()}),s.focus(function(){l.addClass("input-focus")}),s.focusout(function(){l.removeClass("input-focus")}),s.on("input",()=>{""===s.val()?h()?c.removeClass("unloaded"):u.off():(u.on(),h()&&c.addClass("unloaded"))})}),$(function(){var e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,r=0;function a(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||a()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&a()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(!function(){var e=$(this).scrollTop();if(!(Math.abs(r-e)<=o)){if(e>r)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}r=e}}(),e=!1)},250)}),$(function(){var e="div.post>h1:first-of-type",t=$(e);const n=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!n.is(":hidden")){const i=n.text().trim();let r=t.text().trim(),a=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(r)&&(r=r.replace(/[0-9]/g,"").trim()),t.offset().top<$(window).scrollTop()&&n.text(r);new IntersectionObserver(e=>{var t,o;a?(o=$(window).scrollTop(),t=l<o,l=o,o=e[0],t?0===o.intersectionRatio&&n.text(r):1===o.intersectionRatio&&n.text(i)):a=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]}).observe(document.querySelector(e)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(function(){var e,t="#main > div.row:first-child > div:first-child";$(t+" img").length<=0||(e=document.querySelectorAll(t+" img[data-src]"),lozad(e).observe(),$(t+` p > img[data-src], ${t} img[data-src].preview-img`).each(function(){var e=$(this).next(),e="EM"===e.prop("tagName")?e.text():"",t=$(this).attr("data-src");$(this).wrap(`<a href="${t}" title="${e}" class="popup"></a>`)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(t+" a").has("img").addClass("img-link"))}),$(function(){var e=".code-header>button";const t="timeout",a="data-title-succeed",l="data-original-title";function n(e){if($(e)[0].hasAttribute(t)){e=$(e).attr(t);if(Number(e)>Date.now())return 1}}function i(e){$(e).attr(t,Date.now()+2e3)}function s(e){$(e).removeAttr(t)}var o=new ClipboardJS(e,{target(e){return e.parentNode.nextElementSibling.querySelector("code .rouge-code")}});$(e).tooltip({trigger:"hover",placement:"left"});const r=$(e).children().attr("class");o.on("success",e=>{e.clearSelection();const t=e.trigger;var o;n(t)||(e=t,$(e).children().attr("class","fas fa-check"),e=t,o=$(e).attr(a),$(e).attr(l,o).tooltip("show"),i(t),setTimeout(()=>{var e;e=t,$(e).tooltip("hide").removeAttr(l),e=t,$(e).children().attr("class",r),s(t)},2e3))}),$("#copy-link").click(e=>{let t=$(e.target);if(!n(t)){var e=window.location.href,o=$("<input>");$("body").append(o),o.val(e).select(),document.execCommand("copy"),o.remove();const r=t.attr(l);e=t.attr(a);t.attr(l,e).tooltip("show"),i(t),setTimeout(()=>{t.attr(l,r),s(t)},2e3)}})}),$(function(){const e=$("#topbar-title"),s="scroll-focus";$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(a){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){var l=decodeURI(this.hash);let t=RegExp(/^#fnref:/).test(l),o=!t&&RegExp(/^#fn:/).test(l);var n=l.includes(":")?l.replace(/:/g,"\\:"):l;let r=$(n);var n=e.is(":visible"),i=$(window).width()<$(window).height();if(void 0!==r){a.preventDefault(),history.pushState&&history.pushState(null,null,l);a=$(window).scrollTop();let e=r.offset().top-=8;e<a&&(ScrollHelper.hideTopbar(),ScrollHelper.addScrollUpTask()),n&&i&&(e-=ScrollHelper.getTopbarHeight()),$("html").animate({scrollTop:e},500,()=>{if(r.focus(),$(`[${s}=true]`).length&&$(`[${s}=true]`).attr(s,!1),$(":target").length&&$(":target").attr(s,!1),(o||t)&&r.attr(s,!0),r.is(":focus"))return!1;r.attr("tabindex","-1"),r.focus(),ScrollHelper.hasScrollUpTask()&&ScrollHelper.popScrollUpTask()})}}})}); diff --git a/assets/js/dist/post.min.js b/assets/js/dist/post.min.js index 4943c0a..522afc9 100644 --- a/assets/js/dist/post.min.js +++ b/assets/js/dist/post.min.js @@ -1,6 +1,6 @@ /*! - * Chirpy v5.3.0 (https://github.com/cotes2020/jekyll-theme-chirpy/) + * Chirpy v5.3.1 (https://github.com/cotes2020/jekyll-theme-chirpy/) * © 2019 Cotes Chung * MIT Licensed */ -$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(t=>{const e=$(t.target);let o=e.prop("tagName")==="button".toUpperCase()?e:e.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const t=$("body"),e="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,r=!1,l=!1;return{hideTopbar:()=>t.attr(e,!1),showTopbar:()=>t.attr(e,!0),addScrollUpTask:()=>{a+=1,r=r||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0<a,topbarLocked:()=>!0===r,unlockTopbar:()=>r=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===l,lockOrientation:()=>l=!0,unLockOrientation:()=>l=!1}}(),LocaleHelper=($(function(){const t=$("#sidebar-trigger"),e=$("#search-trigger"),o=$("#search-cancel"),a=$("#main"),r=$("#topbar-title"),l=$("#search-wrapper"),n=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),s=$("#search-hints"),d=function(){let t=0;return{block(){t=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(t)},getOffset(){return t}}}(),p={on(){t.addClass("unloaded"),r.addClass("unloaded"),e.addClass("unloaded"),l.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),l.removeClass("d-flex"),t.removeClass("unloaded"),r.removeClass("unloaded"),e.removeClass("unloaded")}},u=function(){let t=!1;return{on(){t||(d.block(),n.removeClass("unloaded"),a.addClass("unloaded"),t=!0)},off(){t&&(i.empty(),s.hasClass("unloaded")&&s.removeClass("unloaded"),n.addClass("unloaded"),a.removeClass("unloaded"),d.release(),c.val(""),t=!1)},isVisible(){return t}}}();function h(){return o.hasClass("loaded")}e.click(function(){p.on(),u.on(),c.focus()}),o.click(function(){p.off(),u.off()}),c.focus(function(){l.addClass("input-focus")}),c.focusout(function(){l.removeClass("input-focus")}),c.on("input",()=>{""===c.val()?h()?s.removeClass("unloaded"):u.off():(u.on(),h()&&s.addClass("unloaded"))})}),$(function(){var t=function(){const t="sidebar-display";let e=!1;const o=$("body");return{toggle(){!1===e?o.attr(t,""):o.removeAttr(t),e=!e}}}();$("#sidebar-trigger").click(t.toggle),$("#mask").click(t.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#search-input"),o=ScrollHelper.getTopbarHeight();let t,a=0;function r(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var t=screen.orientation.type;"landscape-primary"!==t&&"landscape-secondary"!==t||r()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&r()}),$(window).scroll(()=>{t=t||!0}),setInterval(()=>{t&&(!function(){var t=$(this).scrollTop();if(!(Math.abs(a-t)<=o)){if(t>a)ScrollHelper.hideTopbar(),e.is(":focus")&&e.blur();else if(t+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=t}}(),t=!1)},250)}),$(function(){var e="div.post>h1:first-of-type";const o=$(e),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const i=n.text().trim();let a=o.text().trim(),r=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(a);let t=new IntersectionObserver(t=>{var e,o;r?(o=$(window).scrollTop(),e=l<o,l=o,o=t[0],e?0===o.intersectionRatio&&n.text(a):1===o.intersectionRatio&&n.text(i)):r=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]});t.observe(document.querySelector(e)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(function(){var t="#main > div.row:first-child > div:first-child";if(!($(t+" img").length<=0)){var e=document.querySelectorAll(t+" img[data-src]");const o=lozad(e);o.observe(),$(t+` p > img[data-src],${t} img[data-src].preview-img`).each(function(){let t=$(this).next();var e="EM"===t.prop("tagName")?t.text():"",o=$(this).attr("data-src");$(this).wrap(`<a href="${o}" title="${e}" class="popup"></a>`)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(t+" a").has("img").addClass("img-link")}}),function(){const t=$('meta[name="prefer-datetime-locale"]'),e=0<t.length?t.attr("content").toLowerCase():$("html").attr("lang").substr(0,2),o="data-ts",a="data-df";return{locale:()=>e,attrTimestamp:()=>o,attrDateFormat:()=>a,getTimestamp:t=>Number(t.attr(o)),getDateFormat:t=>t.attr(a)}}());$(function(){dayjs.locale(LocaleHelper.locale()),dayjs.extend(window.dayjs_plugin_localizedFormat),$(`[${LocaleHelper.attrTimestamp()}]`).each(function(){const t=dayjs.unix(LocaleHelper.getTimestamp($(this)));var e=t.format(LocaleHelper.getDateFormat($(this))),e=($(this).text(e),$(this).removeAttr(LocaleHelper.attrTimestamp()),$(this).removeAttr(LocaleHelper.attrDateFormat()),$(this).attr("data-toggle"));void 0!==e&&"tooltip"===e&&(e=t.format("llll"),$(this).attr("data-original-title",e))})}),$(function(){$("input[type=checkbox]").addClass("unloaded"),$("input[type=checkbox][checked]").before('<i class="fas fa-check-circle checked"></i>'),$("input[type=checkbox]:not([checked])").before('<i class="far fa-circle"></i>')}),$(function(){var t=".code-header>button";const e="timeout",r="data-title-succeed",l="data-original-title";function n(t){if($(t)[0].hasAttribute(e)){t=$(t).attr(e);if(Number(t)>Date.now())return 1}}function i(t){$(t).attr(e,Date.now()+2e3)}function c(t){$(t).removeAttr(e)}const o=new ClipboardJS(t,{target(t){let e=t.parentNode.nextElementSibling;return e.querySelector("code .rouge-code")}});$(t).tooltip({trigger:"hover",placement:"left"});const s=function(t){let e=$(t).children();return e.attr("class")}(t);o.on("success",o=>{o.clearSelection();const a=o.trigger;if(!n(a)){{o=a;let t=$(o),e=t.children();e.attr("class","fas fa-check")}var t;o=a,t=$(o).attr(r),$(o).attr(l,t).tooltip("show"),i(a),setTimeout(()=>{o=a,$(o).tooltip("hide").removeAttr(l);{var o=a;let t=$(o),e=t.children();e.attr("class",s)}c(a)},2e3)}}),$("#copy-link").click(t=>{let e=$(t.target);if(!n(e)){t=window.location.href;const o=$("<input>"),a=($("body").append(o),o.val(t).select(),document.execCommand("copy"),o.remove(),e.attr(l));t=e.attr(r);e.attr(l,t).tooltip("show"),i(e),setTimeout(()=>{e.attr(l,a),c(e)},2e3)}})}),$(function(){const t=$("#topbar-title"),c="scroll-focus";$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(r){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const i=decodeURI(this.hash);let e=RegExp(/^#fnref:/).test(i),o=!e&&RegExp(/^#fn:/).test(i);var l=i.includes(":")?i.replace(/\:/g,"\\:"):i;let a=$(l);var l=t.is(":visible"),n=$(window).width()<$(window).height();if(void 0!==a){r.preventDefault(),history.pushState&&history.pushState(null,null,i);r=$(window).scrollTop();let t=a.offset().top-=8;t<r&&(ScrollHelper.hideTopbar(),ScrollHelper.addScrollUpTask()),l&&n&&(t-=ScrollHelper.getTopbarHeight()),$("html").animate({scrollTop:t},500,()=>{if(a.focus(),$(`[${c}=true]`).length&&$(`[${c}=true]`).attr(c,!1),$(":target").length&&$(":target").attr(c,!1),(o||e)&&a.attr(c,!0),a.is(":focus"))return!1;a.attr("tabindex","-1"),a.focus(),ScrollHelper.hasScrollUpTask()&&ScrollHelper.popScrollUpTask()})}}})}); \ No newline at end of file +$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(t=>{t=$(t.target);(t.prop("tagName")==="button".toUpperCase()?t:t.parent()).blur(),flipMode()})});const ScrollHelper=function(){const t=$("body"),e="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,r=!1,l=!1;return{hideTopbar:()=>t.attr(e,!1),showTopbar:()=>t.attr(e,!0),addScrollUpTask:()=>{a+=1,r=r||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0<a,topbarLocked:()=>!0===r,unlockTopbar:()=>r=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===l,lockOrientation:()=>l=!0,unLockOrientation:()=>l=!1}}(),LocaleHelper=($(function(){const t=$("#sidebar-trigger"),e=$("#search-trigger"),o=$("#search-cancel"),a=$("#main"),r=$("#topbar-title"),l=$("#search-wrapper"),n=$("#search-result-wrapper"),i=$("#search-results"),s=$("#search-input"),c=$("#search-hints"),d=function(){let t=0;return{block(){t=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(t)},getOffset(){return t}}}(),p={on(){t.addClass("unloaded"),r.addClass("unloaded"),e.addClass("unloaded"),l.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),l.removeClass("d-flex"),t.removeClass("unloaded"),r.removeClass("unloaded"),e.removeClass("unloaded")}},u=function(){let t=!1;return{on(){t||(d.block(),n.removeClass("unloaded"),a.addClass("unloaded"),t=!0)},off(){t&&(i.empty(),c.hasClass("unloaded")&&c.removeClass("unloaded"),n.addClass("unloaded"),a.removeClass("unloaded"),d.release(),s.val(""),t=!1)},isVisible(){return t}}}();function h(){return o.hasClass("loaded")}e.click(function(){p.on(),u.on(),s.focus()}),o.click(function(){p.off(),u.off()}),s.focus(function(){l.addClass("input-focus")}),s.focusout(function(){l.removeClass("input-focus")}),s.on("input",()=>{""===s.val()?h()?c.removeClass("unloaded"):u.off():(u.on(),h()&&c.addClass("unloaded"))})}),$(function(){var t=function(){const t="sidebar-display";let e=!1;const o=$("body");return{toggle(){!1===e?o.attr(t,""):o.removeAttr(t),e=!e}}}();$("#sidebar-trigger").click(t.toggle),$("#mask").click(t.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#search-input"),o=ScrollHelper.getTopbarHeight();let t,a=0;function r(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var t=screen.orientation.type;"landscape-primary"!==t&&"landscape-secondary"!==t||r()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&r()}),$(window).scroll(()=>{t=t||!0}),setInterval(()=>{t&&(!function(){var t=$(this).scrollTop();if(!(Math.abs(a-t)<=o)){if(t>a)ScrollHelper.hideTopbar(),e.is(":focus")&&e.blur();else if(t+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=t}}(),t=!1)},250)}),$(function(){var t="div.post>h1:first-of-type",e=$(t);const n=$("#topbar-title");if(0!==e.length&&!e.hasClass("dynamic-title")&&!n.is(":hidden")){const i=n.text().trim();let a=e.text().trim(),r=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),e.offset().top<$(window).scrollTop()&&n.text(a);new IntersectionObserver(t=>{var e,o;r?(o=$(window).scrollTop(),e=l<o,l=o,o=t[0],e?0===o.intersectionRatio&&n.text(a):1===o.intersectionRatio&&n.text(i)):r=!0},{rootMargin:"-48px 0px 0px 0px",threshold:[0,1]}).observe(document.querySelector(t)),n.click(function(){$("body,html").animate({scrollTop:0},800)})}}),$(function(){var t,e="#main > div.row:first-child > div:first-child";$(e+" img").length<=0||(t=document.querySelectorAll(e+" img[data-src]"),lozad(t).observe(),$(e+` p > img[data-src], ${e} img[data-src].preview-img`).each(function(){var t=$(this).next(),t="EM"===t.prop("tagName")?t.text():"",e=$(this).attr("data-src");$(this).wrap(`<a href="${e}" title="${t}" class="popup"></a>`)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(e+" a").has("img").addClass("img-link"))}),function(){const t=$("html").attr("lang").substr(0,2),e="data-ts",o="data-df";return{locale:()=>t,attrTimestamp:()=>e,attrDateFormat:()=>o,getTimestamp:t=>Number(t.attr(e)),getDateFormat:t=>t.attr(o)}}());$(function(){dayjs.locale(LocaleHelper.locale()),dayjs.extend(window.dayjs_plugin_localizedFormat),$(`[${LocaleHelper.attrTimestamp()}]`).each(function(){var t=dayjs.unix(LocaleHelper.getTimestamp($(this))),e=t.format(LocaleHelper.getDateFormat($(this))),e=($(this).text(e),$(this).removeAttr(LocaleHelper.attrTimestamp()),$(this).removeAttr(LocaleHelper.attrDateFormat()),$(this).attr("data-toggle"));void 0!==e&&"tooltip"===e&&(e=t.format("llll"),$(this).attr("data-original-title",e))})}),$(function(){var t=".code-header>button";const e="timeout",r="data-title-succeed",l="data-original-title";function n(t){if($(t)[0].hasAttribute(e)){t=$(t).attr(e);if(Number(t)>Date.now())return 1}}function i(t){$(t).attr(e,Date.now()+2e3)}function s(t){$(t).removeAttr(e)}var o=new ClipboardJS(t,{target(t){return t.parentNode.nextElementSibling.querySelector("code .rouge-code")}});$(t).tooltip({trigger:"hover",placement:"left"});const a=$(t).children().attr("class");o.on("success",t=>{t.clearSelection();const e=t.trigger;var o;n(e)||(t=e,$(t).children().attr("class","fas fa-check"),t=e,o=$(t).attr(r),$(t).attr(l,o).tooltip("show"),i(e),setTimeout(()=>{var t;t=e,$(t).tooltip("hide").removeAttr(l),t=e,$(t).children().attr("class",a),s(e)},2e3))}),$("#copy-link").click(t=>{let e=$(t.target);if(!n(e)){var t=window.location.href,o=$("<input>");$("body").append(o),o.val(t).select(),document.execCommand("copy"),o.remove();const a=e.attr(l);t=e.attr(r);e.attr(l,t).tooltip("show"),i(e),setTimeout(()=>{e.attr(l,a),s(e)},2e3)}})}),$(function(){const t=$("#topbar-title"),s="scroll-focus";$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(r){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){var l=decodeURI(this.hash);let e=RegExp(/^#fnref:/).test(l),o=!e&&RegExp(/^#fn:/).test(l);var n=l.includes(":")?l.replace(/:/g,"\\:"):l;let a=$(n);var n=t.is(":visible"),i=$(window).width()<$(window).height();if(void 0!==a){r.preventDefault(),history.pushState&&history.pushState(null,null,l);r=$(window).scrollTop();let t=a.offset().top-=8;t<r&&(ScrollHelper.hideTopbar(),ScrollHelper.addScrollUpTask()),n&&i&&(t-=ScrollHelper.getTopbarHeight()),$("html").animate({scrollTop:t},500,()=>{if(a.focus(),$(`[${s}=true]`).length&&$(`[${s}=true]`).attr(s,!1),$(":target").length&&$(":target").attr(s,!1),(o||e)&&a.attr(s,!0),a.is(":focus"))return!1;a.attr("tabindex","-1"),a.focus(),ScrollHelper.hasScrollUpTask()&&ScrollHelper.popScrollUpTask()})}}})}); diff --git a/assets/js/dist/pvreport.min.js b/assets/js/dist/pvreport.min.js index ffa5f47..6dce45c 100644 --- a/assets/js/dist/pvreport.min.js +++ b/assets/js/dist/pvreport.min.js @@ -1,6 +1,6 @@ /*! - * Chirpy v5.3.0 (https://github.com/cotes2020/jekyll-theme-chirpy/) + * Chirpy v5.3.1 (https://github.com/cotes2020/jekyll-theme-chirpy/) * © 2019 Cotes Chung * MIT Licensed */ -const getInitStatus=function(){let t=!1;return()=>{var e=t;return t=t||!0,e}}(),PvOpts=function(){function t(e){return $(e).attr("content")}function e(e){e=t(e);return void 0!==e&&!1!==e}return{getProxyMeta(){return t("meta[name=pv-proxy-endpoint]")},getLocalMeta(){return t("meta[name=pv-cache-path]")},hasProxyMeta(){return e("meta[name=pv-proxy-endpoint]")},hasLocalMeta(){return e("meta[name=pv-cache-path]")}}}(),PvStorage=function(){const a={KEY_PV:"pv",KEY_PV_SRC:"pv_src",KEY_CREATION:"pv_created_date"},t={LOCAL:"same-origin",PROXY:"cors"};function r(e){return localStorage.getItem(e)}function o(e,t){localStorage.setItem(e,t)}function n(e,t){o(a.KEY_PV,e),o(a.KEY_PV_SRC,t),o(a.KEY_CREATION,(new Date).toJSON())}return{keysCount(){return Object.keys(a).length},hasCache(){return null!==localStorage.getItem(a.KEY_PV)},getCache(){return JSON.parse(localStorage.getItem(a.KEY_PV))},saveLocalCache(e){n(e,t.LOCAL)},saveProxyCache(e){n(e,t.PROXY)},isExpired(){let e=new Date(r(a.KEY_CREATION));return e.setHours(e.getHours()+1),Date.now()>=e.getTime()},isFromLocal(){return r(a.KEY_PV_SRC)===t.LOCAL},isFromProxy(){return r(a.KEY_PV_SRC)===t.PROXY},newerThan(e){return PvStorage.getCache().totalsForAllResults["ga:pageviews"]>e.totalsForAllResults["ga:pageviews"]},inspectKeys(){if(localStorage.length!==PvStorage.keysCount())localStorage.clear();else for(let e=0;e<localStorage.length;e++)switch(localStorage.key(e)){case a.KEY_PV:case a.KEY_PV_SRC:case a.KEY_CREATION:break;default:return void localStorage.clear()}}}}();function countUp(t,a,r){if(t<a){let e=new CountUp(r,t,a);e.error?console.error(e.error):e.start()}}function countPV(t,a){let r=0;if(void 0!==a)for(let e=0;e<a.length;++e)if(a[parseInt(e,10)][0]===t){r+=parseInt(a[parseInt(e,10)][1],10);break}return r}function tacklePV(e,t,a,r){let o=countPV(t,e);o=0===o?1:o,r?(t=parseInt(a.text().replace(/,/g,""),10),o>t&&countUp(t,o,a.attr("id"))):a.text((new Intl.NumberFormat).format(o))}function displayPageviews(e){if(void 0!==e){let t=getInitStatus();const a=e.rows;0<$("#post-list").length?$(".post-preview").each(function(){var e=$(this).find("a").attr("href");tacklePV(a,e,$(this).find(".pageviews"),t)}):0<$(".post").length&&(e=window.location.pathname,tacklePV(a,e,$("#pv"),t))}}function fetchProxyPageviews(){PvOpts.hasProxyMeta()&&$.ajax({type:"GET",url:PvOpts.getProxyMeta(),dataType:"jsonp",jsonpCallback:"displayPageviews",success:e=>{PvStorage.saveProxyCache(JSON.stringify(e))},error:(e,t,a)=>{console.log("Failed to load pageviews from proxy server: "+a)}})}function fetchLocalPageviews(t=!1){return fetch(PvOpts.getLocalMeta()).then(e=>e.json()).then(e=>{t&&PvStorage.isFromProxy()&&PvStorage.newerThan(e)||(displayPageviews(e),PvStorage.saveLocalCache(JSON.stringify(e)))})}$(function(){$(".pageviews").length<=0||(PvStorage.inspectKeys(),PvStorage.hasCache()?(displayPageviews(PvStorage.getCache()),PvStorage.isExpired()?PvOpts.hasLocalMeta()?fetchLocalPageviews(!0).then(fetchProxyPageviews):fetchProxyPageviews():PvStorage.isFromLocal()&&fetchProxyPageviews()):PvOpts.hasLocalMeta()?fetchLocalPageviews().then(fetchProxyPageviews):fetchProxyPageviews())}); \ No newline at end of file +const getInitStatus=function(){let t=!1;return()=>{var e=t;return t=t||!0,e}}(),PvOpts=function(){function t(e){return $(e).attr("content")}function e(e){e=t(e);return void 0!==e&&!1!==e}return{getProxyMeta(){return t("meta[name=pv-proxy-endpoint]")},getLocalMeta(){return t("meta[name=pv-cache-path]")},hasProxyMeta(){return e("meta[name=pv-proxy-endpoint]")},hasLocalMeta(){return e("meta[name=pv-cache-path]")}}}(),PvStorage=function(){const a={KEY_PV:"pv",KEY_PV_SRC:"pv_src",KEY_CREATION:"pv_created_date"},t={LOCAL:"same-origin",PROXY:"cors"};function r(e){return localStorage.getItem(e)}function o(e,t){localStorage.setItem(e,t)}function n(e,t){o(a.KEY_PV,e),o(a.KEY_PV_SRC,t),o(a.KEY_CREATION,(new Date).toJSON())}return{keysCount(){return Object.keys(a).length},hasCache(){return null!==localStorage.getItem(a.KEY_PV)},getCache(){return JSON.parse(localStorage.getItem(a.KEY_PV))},saveLocalCache(e){n(e,t.LOCAL)},saveProxyCache(e){n(e,t.PROXY)},isExpired(){var e=new Date(r(a.KEY_CREATION));return e.setHours(e.getHours()+1),Date.now()>=e.getTime()},isFromLocal(){return r(a.KEY_PV_SRC)===t.LOCAL},isFromProxy(){return r(a.KEY_PV_SRC)===t.PROXY},newerThan(e){return PvStorage.getCache().totalsForAllResults["ga:pageviews"]>e.totalsForAllResults["ga:pageviews"]},inspectKeys(){if(localStorage.length!==PvStorage.keysCount())localStorage.clear();else for(let e=0;e<localStorage.length;e++)switch(localStorage.key(e)){case a.KEY_PV:case a.KEY_PV_SRC:case a.KEY_CREATION:break;default:return void localStorage.clear()}}}}();function countUp(e,t,a){e<t&&((a=new CountUp(a,e,t)).error?console.error(a.error):a.start())}function countPV(t,a){let r=0;if(void 0!==a)for(let e=0;e<a.length;++e)if(a[parseInt(e,10)][0]===t){r+=parseInt(a[parseInt(e,10)][1],10);break}return r}function tacklePV(e,t,a,r){t=0===(t=countPV(t,e))?1:t;r?(e=parseInt(a.text().replace(/,/g,""),10))<t&&countUp(e,t,a.attr("id")):a.text((new Intl.NumberFormat).format(t))}function displayPageviews(e){if(void 0!==e){let t=getInitStatus();const a=e.rows;0<$("#post-list").length?$(".post-preview").each(function(){var e=$(this).find("a").attr("href");tacklePV(a,e,$(this).find(".pageviews"),t)}):0<$(".post").length&&(e=window.location.pathname,tacklePV(a,e,$("#pv"),t))}}function fetchProxyPageviews(){PvOpts.hasProxyMeta()&&$.ajax({type:"GET",url:PvOpts.getProxyMeta(),dataType:"jsonp",jsonpCallback:"displayPageviews",success:e=>{PvStorage.saveProxyCache(JSON.stringify(e))},error:(e,t,a)=>{console.log("Failed to load pageviews from proxy server: "+a)}})}function fetchLocalPageviews(t=!1){return fetch(PvOpts.getLocalMeta()).then(e=>e.json()).then(e=>{t&&PvStorage.isFromProxy()&&PvStorage.newerThan(e)||(displayPageviews(e),PvStorage.saveLocalCache(JSON.stringify(e)))})}$(function(){$(".pageviews").length<=0||(PvStorage.inspectKeys(),PvStorage.hasCache()?(displayPageviews(PvStorage.getCache()),PvStorage.isExpired()?PvOpts.hasLocalMeta()?fetchLocalPageviews(!0).then(fetchProxyPageviews):fetchProxyPageviews():PvStorage.isFromLocal()&&fetchProxyPageviews()):PvOpts.hasLocalMeta()?fetchLocalPageviews().then(fetchProxyPageviews):fetchProxyPageviews())}); diff --git a/assets/js/pwa/app.js b/assets/js/pwa/app.js index ab4b174..c798fe2 100644 --- a/assets/js/pwa/app.js +++ b/assets/js/pwa/app.js @@ -7,41 +7,41 @@ const $notification = $('#notification'); const $btnRefresh = $('#notification .toast-body>button'); if ('serviceWorker' in navigator) { - /* Registering Service Worker */ - navigator.serviceWorker.register('{{ "/sw.js" | relative_url }}') - .then(registration => { + /* Registering Service Worker */ + navigator.serviceWorker.register('{{ "/sw.js" | relative_url }}') + .then(registration => { - /* in case the user ignores the notification */ - if (registration.waiting) { - $notification.toast('show'); - } - - registration.addEventListener('updatefound', () => { - registration.installing.addEventListener('statechange', () => { - if (registration.waiting) { - if (navigator.serviceWorker.controller) { - $notification.toast('show'); + /* in case the user ignores the notification */ + if (registration.waiting) { + $notification.toast('show'); } - } + + registration.addEventListener('updatefound', () => { + registration.installing.addEventListener('statechange', () => { + if (registration.waiting) { + if (navigator.serviceWorker.controller) { + $notification.toast('show'); + } + } + }); + }); + + $btnRefresh.click(() => { + if (registration.waiting) { + registration.waiting.postMessage('SKIP_WAITING'); + } + $notification.toast('hide'); + }); }); - }); - $btnRefresh.click(() => { - if (registration.waiting) { - registration.waiting.postMessage('SKIP_WAITING'); + let refreshing = false; + + /* Detect controller change and refresh all the opened tabs */ + navigator.serviceWorker.addEventListener('controllerchange', () => { + if (!refreshing) { + window.location.reload(); + refreshing = true; } - $notification.toast('hide'); - }); - } - ); - - let refreshing = false; - - /* Detect controller change and refresh all the opened tabs */ - navigator.serviceWorker.addEventListener('controllerchange', () => { - if (!refreshing) { - window.location.reload(); - refreshing = true; - } - }); + }); } + diff --git a/assets/js/pwa/sw.js b/assets/js/pwa/sw.js index 7492ac3..3213b4f 100644 --- a/assets/js/pwa/sw.js +++ b/assets/js/pwa/sw.js @@ -9,81 +9,82 @@ self.importScripts('{{ "/assets/js/data/swcache.js" | relative_url }}'); const cacheName = 'chirpy-{{ "now" | date: "%Y%m%d.%H%M%S" }}'; function verifyDomain(url) { - for (const domain of allowedDomains) { - const regex = RegExp(`^http(s)?:\/\/${domain}\/`); - if (regex.test(url)) { - return true; + for (const domain of allowedDomains) { + const regex = RegExp(`^http(s)?:\/\/${domain}\/`); + if (regex.test(url)) { + return true; + } } - } - return false; + return false; } function isExcluded(url) { - for (const item of denyUrls) { - if (url === item) { - return true; + for (const item of denyUrls) { + if (url === item) { + return true; + } } - } - return false; + return false; } self.addEventListener('install', event => { - event.waitUntil( - caches.open(cacheName).then(cache => { - return cache.addAll(resource); - }) - ); + event.waitUntil( + caches.open(cacheName).then(cache => { + return cache.addAll(resource); + }) + ); }); self.addEventListener('activate', event => { - event.waitUntil( - caches.keys().then(keyList => { - return Promise.all( - keyList.map(key => { - if (key !== cacheName) { - return caches.delete(key); - } + event.waitUntil( + caches.keys().then(keyList => { + return Promise.all( + keyList.map(key => { + if (key !== cacheName) { + return caches.delete(key); + } + }) + ); }) - ); - }) - ); + ); }); self.addEventListener('message', (event) => { - if (event.data === 'SKIP_WAITING') { - self.skipWaiting(); - } + if (event.data === 'SKIP_WAITING') { + self.skipWaiting(); + } }); self.addEventListener('fetch', event => { - event.respondWith( - caches.match(event.request).then(response => { - if (response) { - return response; - } + event.respondWith( + caches.match(event.request).then(response => { + if (response) { + return response; + } - return fetch(event.request).then(response => { - const url = event.request.url; + return fetch(event.request).then(response => { + const url = event.request.url; - if (event.request.method !== 'GET' || - !verifyDomain(url) || - isExcluded(url)) { - return response; - } + if (event.request.method !== 'GET' || + !verifyDomain(url) || + isExcluded(url)) { + return response; + } - /* - see: <https://developers.google.com/web/fundamentals/primers/service-workers#cache_and_return_requests> - */ - let responseToCache = response.clone(); + /* + see: <https://developers.google.com/web/fundamentals/primers/service-workers#cache_and_return_requests> + */ + let responseToCache = response.clone(); - caches.open(cacheName).then(cache => { - /* console.log('[sw] Caching new resource: ' + event.request.url); */ - cache.put(event.request, responseToCache); - }); + caches.open(cacheName).then(cache => { + /* console.log('[sw] Caching new resource: ' + event.request.url); */ + cache.put(event.request, responseToCache); + }); - return response; - }); - }) - ); + return response; + }); + }) + ); }); + diff --git a/assets/js/pwa/unregister.js b/assets/js/pwa/unregister.js index da8cbb8..bd91150 100644 --- a/assets/js/pwa/unregister.js +++ b/assets/js/pwa/unregister.js @@ -4,9 +4,9 @@ permalink: '/unregister.js' --- if ('serviceWorker' in navigator) { - navigator.serviceWorker.getRegistrations().then((registrations) => { - for (let reg of registrations) { - reg.unregister(); - } - }); + navigator.serviceWorker.getRegistrations().then((registrations) => { + for (let reg of registrations) { + reg.unregister(); + } + }); } diff --git a/assets/lib b/assets/lib index d1d2ec1..b2842d6 160000 --- a/assets/lib +++ b/assets/lib @@ -1 +1 @@ -Subproject commit d1d2ec17c88176753d4dd2a1296620021dcc22fd +Subproject commit b2842d6583088cb6b33ad50093a39a3e2cf2c026 diff --git a/gulpfile.js/tasks/js.js b/gulpfile.js/tasks/js.js index a1febb7..3db0065 100644 --- a/gulpfile.js/tasks/js.js +++ b/gulpfile.js/tasks/js.js @@ -24,6 +24,7 @@ function minifyJs() { return src(`${ JS_DEST }/*.js`) .pipe(insert.prepend(fs.readFileSync(`${ JS_SRC }/copyright`, 'utf8'))) .pipe(uglify({output: {comments: /^!|@preserve|@license|@cc_on/i}})) + .pipe(insert.append('\n')) .pipe(dest(JS_DEST)); } @@ -45,7 +46,6 @@ const postJs = () => { `${JS_SRC}/commons/*.js`, `${JS_SRC}/utils/img-extra.js`, `${JS_SRC}/utils/locale-datetime.js`, - `${JS_SRC}/utils/checkbox.js`, `${JS_SRC}/utils/clipboard.js`, // 'smooth-scroll.js' must be called after ToC is ready `${JS_SRC}/utils/smooth-scroll.js` @@ -64,7 +64,6 @@ const categoriesJs = () => { const pageJs = () => { return concatJs([ `${JS_SRC}/commons/*.js`, - `${JS_SRC}/utils/checkbox.js`, `${JS_SRC}/utils/img-extra.js`, `${JS_SRC}/utils/clipboard.js`, `${JS_SRC}/utils/smooth-scroll.js` diff --git a/jekyll-theme-chirpy.gemspec b/jekyll-theme-chirpy.gemspec index 70730e5..34c3590 100644 --- a/jekyll-theme-chirpy.gemspec +++ b/jekyll-theme-chirpy.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |spec| spec.name = "jekyll-theme-chirpy" - spec.version = "5.3.0" + spec.version = "5.3.1" spec.authors = ["Cotes Chung"] spec.email = ["cotes.chung@gmail.com"] @@ -11,7 +11,7 @@ Gem::Specification.new do |spec| spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0").select { |f| - f.match(%r!^((_(includes|layouts|sass|data|tabs|plugins)|assets)\/|_config|README|LICENSE|index)!i) + f.match(%r!^((_(includes|layouts|sass|data)|assets)\/|README|LICENSE)!i) } spec.metadata = { diff --git a/package.json b/package.json index 4ae4048..8abb7ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jekyll-theme-chirpy", - "version": "5.3.0", + "version": "5.3.1", "description": "A minimal, responsive, and powerful Jekyll theme for presenting professional writing.", "repository": { "type": "git", @@ -12,12 +12,18 @@ "url": "https://github.com/cotes2020/jekyll-theme-chirpy/issues" }, "homepage": "https://github.com/cotes2020/jekyll-theme-chirpy#readme", + "scripts": { + "test": "npx stylelint _sass/**/*.scss", + "fixlint": "npx stylelint _sass/**/*.scss --fix" + }, "devDependencies": { "gulp": "^4.0.2", "gulp-concat": "^2.6.1", "gulp-insert": "^0.5.0", "gulp-rename": "^2.0.0", "gulp-uglify": "^3.0.2", + "stylelint": "^14.14.0", + "stylelint-config-standard-scss": "^5.0.0", "uglify-js": "^3.14.3" } } diff --git a/tools/release.sh b/tools/release.sh index d812b67..0f5d85f 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -14,7 +14,8 @@ set -eu -opt_pre=false # preview mode option +opt_pre=false # preview mode option +opt_skip_ver=false # option for skip versioning working_branch="$(git branch --show-current)" @@ -48,6 +49,7 @@ help() { echo " bash ./tools/release.sh [options]" echo echo "Options:" + echo " -k, --skip-versioning Skip the step of generating the version number." echo " -p, --preview Enable preview mode, only package, and will not modify the branches" echo " -h, --help Print this information." } @@ -170,13 +172,15 @@ release() { } main() { - check + if [[ $opt_skip_ver = false ]]; then + check - # auto-generate a new version number to the file 'package.json' - if $opt_pre; then - standard-version --prerelease rc - else - standard-version + # auto-generate a new version number to the file 'package.json' + if $opt_pre; then + standard-version --prerelease rc + else + standard-version + fi fi _version="$(grep '"version":' package.json | sed 's/.*: "//;s/".*//')" @@ -201,6 +205,10 @@ while (($#)); do opt_pre=true shift ;; + -k | --skip-versioning) + opt_skip_ver=true + shift + ;; -h | --help) help exit 0 diff --git a/tools/test.sh b/tools/test.sh index 155df3e..a647bde 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -12,6 +12,8 @@ SITE_DIR="_site" _config="_config.yml" +_baseurl="" + help() { echo "Build and test the site content" echo @@ -24,18 +26,39 @@ help() { echo " -h, --help Print this information." } +read_baseurl() { + if [[ $_config == *","* ]]; then + # multiple config + IFS="," + read -ra config_array <<<"$_config" + + # reverse loop the config files + for ((i = ${#config_array[@]} - 1; i >= 0; i--)); do + _tmp_baseurl="$(grep '^baseurl:' "${config_array[i]}" | sed "s/.*: *//;s/['\"]//g;s/#.*//")" + + if [[ -n $_tmp_baseurl ]]; then + _baseurl="$_tmp_baseurl" + break + fi + done + + else + # single config + _baseurl="$(grep '^baseurl:' "$_config" | sed "s/.*: *//;s/['\"]//g;s/#.*//")" + fi +} + main() { # clean up if [[ -d $SITE_DIR ]]; then rm -rf "$SITE_DIR" fi - _baseurl="$(grep '^baseurl:' "$_config" | sed "s/.*: *//;s/['\"]//g;s/#.*//")" + read_baseurl # build - JEKYLL_ENV=production bundle exec jekyll build \ - --destination "$SITE_DIR$_baseurl" \ - --config "$_config" + JEKYLL_ENV=production bundle exec jekyll b \ + -d "$SITE_DIR$_baseurl" -c "$_config" # test bundle exec htmlproofer "$SITE_DIR" \