From b4019f3517e4a3284df51567d29938cb12bf3acc Mon Sep 17 00:00:00 2001 From: Alexander Fuks Date: Sat, 30 Nov 2024 23:07:53 +0300 Subject: [PATCH 1/7] fix: ensure pageviews are fetched after DOM is loaded (#2071) --- _includes/pageviews/goatcounter.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/_includes/pageviews/goatcounter.html b/_includes/pageviews/goatcounter.html index e62fd698d9b..20719b43c07 100644 --- a/_includes/pageviews/goatcounter.html +++ b/_includes/pageviews/goatcounter.html @@ -1,12 +1,13 @@ From 8e55e4dcb25b02c667105deea7932ed344a0db6c Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sun, 1 Dec 2024 04:20:47 +0800 Subject: [PATCH 2/7] build: correct the js rollup watch path (#2074) 1. Correct the rollup watch path 2. Avoid registering watch listeners redundantly across multiple tasks --- rollup.config.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index 3a1ae29ada6..0e8a6c74b9a 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -11,11 +11,11 @@ const DIST = 'assets/js/dist'; const banner = `/*! * ${pkg.name} v${pkg.version} | © ${pkg.since} ${pkg.author} | ${pkg.license} Licensed | ${pkg.homepage} */`; - const frontmatter = `---\npermalink: /:basename\n---\n`; - const isProd = process.env.BUILD === 'production'; +let hasWatched = false; + function cleanup() { fs.rmSync(DIST, { recursive: true, force: true }); console.log(`> Directory "${DIST}" has been cleaned.`); @@ -39,6 +39,11 @@ function build( { src = SRC_DEFAULT, jekyll = false, outputName = null } = {} ) { const input = `${src}/${filename}.js`; + const shouldWatch = hasWatched ? false : true; + + if (!hasWatched) { + hasWatched = true; + } return { input, @@ -49,9 +54,7 @@ function build( banner, sourcemap: !isProd && !jekyll }, - watch: { - include: input - }, + ...(shouldWatch && { watch: { include: `${SRC_DEFAULT}/**/*.js` } }), plugins: [ babel({ babelHelpers: 'bundled', From a16aa7d41e3c3cb28649bfa1361e8bcb91b9ca47 Mon Sep 17 00:00:00 2001 From: Alexander Fuks Date: Sat, 30 Nov 2024 23:34:12 +0300 Subject: [PATCH 3/7] fix: correct the import condition for theme script (#2075) --- _includes/head.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/_includes/head.html b/_includes/head.html index 011187c960d..4514666a541 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -99,9 +99,7 @@ - {% unless site.theme_mode %} - - {% endunless %} + {% include js-selector.html lang=lang %} From 418099227222baac6c7dab74d40de751325ffd82 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Tue, 3 Dec 2024 22:22:20 +0800 Subject: [PATCH 4/7] style: add indentation to js code --- _includes/pageviews/goatcounter.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/_includes/pageviews/goatcounter.html b/_includes/pageviews/goatcounter.html index 20719b43c07..265b22430c8 100644 --- a/_includes/pageviews/goatcounter.html +++ b/_includes/pageviews/goatcounter.html @@ -8,14 +8,14 @@ const url = `https://{{ site.analytics.goatcounter.id }}.goatcounter.com/counter/${encodeURIComponent(uri)}.json`; fetch(url) - .then((response) => response.json()) - .then((data) => { - const count = data.count.replace(/\s/g, ''); - pv.innerText = new Intl.NumberFormat().format(count); - }) - .catch((error) => { - pv.innerText = '1'; - }); + .then((response) => response.json()) + .then((data) => { + const count = data.count.replace(/\s/g, ''); + pv.innerText = new Intl.NumberFormat().format(count); + }) + .catch((error) => { + pv.innerText = '1'; + }); } }); From 8280adb901b9d15cc1bc18009553aae8746121d8 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Tue, 3 Dec 2024 22:41:28 +0800 Subject: [PATCH 5/7] fix(toc): resume fade up animation in desktop mode (#2085) --- _includes/toc.html | 2 +- _javascript/modules/components/toc/toc-desktop.js | 5 ++++- _sass/pages/_post.scss | 5 +---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/_includes/toc.html b/_includes/toc.html index 883bf135d55..4dccb2a6cf7 100644 --- a/_includes/toc.html +++ b/_includes/toc.html @@ -2,7 +2,7 @@ {% if enable_toc %}
-
+ diff --git a/_javascript/modules/components/toc/toc-desktop.js b/_javascript/modules/components/toc/toc-desktop.js index 5021a72a082..0aaba48fcc7 100644 --- a/_javascript/modules/components/toc/toc-desktop.js +++ b/_javascript/modules/components/toc/toc-desktop.js @@ -15,8 +15,11 @@ export class TocDesktop { } static init() { - if (document.getElementById('toc-wrapper')) { + const $tocWrapper = document.getElementById('toc-wrapper'); + + if ($tocWrapper) { tocbot.init(this.options); + $tocWrapper.classList.remove('invisible'); } } } diff --git a/_sass/pages/_post.scss b/_sass/pages/_post.scss index 19adf3fa66e..caa2fe6ece2 100644 --- a/_sass/pages/_post.scss +++ b/_sass/pages/_post.scss @@ -234,14 +234,11 @@ header { @keyframes fade-up { from { opacity: 0; - position: relative; - top: 2rem; + margin-top: 4rem; } to { opacity: 1; - position: relative; - top: 0; } } From 7ea3545ba3748a25cd234bbaaed3a4e47055ed97 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Thu, 5 Dec 2024 21:09:07 +0800 Subject: [PATCH 6/7] refactor: reduce the height of the TOC bottom overlay in desktop mode --- _includes/toc.html | 2 +- _sass/pages/_post.scss | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/_includes/toc.html b/_includes/toc.html index 4dccb2a6cf7..0f877267b39 100644 --- a/_includes/toc.html +++ b/_includes/toc.html @@ -2,7 +2,7 @@ {% if enable_toc %}
-