From c5d11441bcea97711d8ac27be43f1e011c404a3a Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sat, 13 Jan 2024 22:13:15 +0800 Subject: [PATCH 01/18] build(deps-dev): install `husky` and `commitlint` locally Signed-off-by: Cotes Chung <11371340+cotes2020@users.noreply.github.com> --- .husky/commit-msg | 2 +- package.json | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index 4037788..7f23494 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -npx --no -- commitlint -x $(npm root -g)/@commitlint/config-conventional --edit +npx --no -- commitlint --edit ${1} diff --git a/package.json b/package.json index b461b64..334a506 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,11 @@ "@babel/core": "^7.23.7", "@babel/plugin-proposal-class-properties": "^7.18.6", "@babel/preset-env": "^7.23.7", + "@commitlint/cli": "^18.4.4", + "@commitlint/config-conventional": "^18.4.4", "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-terser": "^0.4.4", + "husky": "^8.0.3", "rimraf": "^5.0.5", "rollup": "^4.9.2", "rollup-plugin-license": "^3.2.0", @@ -41,6 +44,9 @@ "not dead" ], "commitlint": { + "extends": [ + "@commitlint/config-conventional" + ], "rules": { "body-max-line-length": [ 0, From 4facf5b390eeba612ca439f3354c5d2d881aac56 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Fri, 19 Jan 2024 05:48:26 +0800 Subject: [PATCH 02/18] perf: allow no social links to be configured (#1494) --- _includes/footer.html | 10 ++++++++-- _sass/addon/commons.scss | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/_includes/footer.html b/_includes/footer.html index a992355..a015f46 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -8,9 +8,15 @@ " >

- {{ '©' }} + {{- '©' }} - {{ site.social.name }}. + + {% if site.social.links %} + {{ site.social.name }}. + {% else %} + {{ site.social.name }}. + {% endif %} + {% if site.data.locales[include.lang].copyright.brief %} Date: Fri, 19 Jan 2024 06:19:20 +0800 Subject: [PATCH 03/18] fix: missing "/" at the end of URLs for categories and tags in breadcrumb (#1495) --- _includes/topbar.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_includes/topbar.html b/_includes/topbar.html index 3d079ed..d85101a 100644 --- a/_includes/topbar.html +++ b/_includes/topbar.html @@ -17,7 +17,7 @@ {% if forloop.first %} - {{ site.data.locales[include.lang].tabs.home | capitalize }} + {{- site.data.locales[include.lang].tabs.home | capitalize -}} @@ -30,8 +30,8 @@ {% elsif page.layout == 'category' or page.layout == 'tag' %} - - {{ site.data.locales[include.lang].tabs[item] | default: page.title }} + + {{- site.data.locales[include.lang].tabs[item] | default: page.title -}} {% endif %} From c0018b66f3a182d1dca6ead379b5c530c4ede3e5 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Mon, 22 Jan 2024 01:57:55 +0800 Subject: [PATCH 04/18] build(editor): add VS Code config Make it easy to initialize the development environment. --- .gitignore | 1 - .vscode/extensions.json | 12 ++++++++++++ .vscode/settings.json | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 0124b68..cee9e12 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,6 @@ package-lock.json # IDE configurations .idea -.vscode # Misc assets/js/dist diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..6927cd1 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,12 @@ +{ + "recommendations": [ + // Liquid tags auto-complete + "killalau.vscode-liquid-snippets", + // Liquid syntax highlighting and formatting + "Shopify.theme-check-vscode", + // Common formatter + "esbenp.prettier-vscode", + "foxundermoon.shell-format", + "stylelint.vscode-stylelint" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4fcded4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,24 @@ +{ + // Prettier + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "prettier.trailingComma": "none", + // Shopify Liquid + "files.associations": { + "*.html": "liquid" + }, + // Formatter + "[html][liquid]": { + "editor.defaultFormatter": "Shopify.theme-check-vscode" + }, + "[shellscript]": { + "editor.defaultFormatter": "foxundermoon.shell-format" + }, + // Disable vscode built-in stylelint + "css.validate": false, + "scss.validate": false, + "less.validate": false, + // Stylint extension settings + "stylelint.snippet": ["css", "less", "postcss", "scss"], + "stylelint.validate": ["css", "less", "postcss", "scss"] +} From ea3a22e13c1ba86ed09d85fc9ca98ef9b43bb6cb Mon Sep 17 00:00:00 2001 From: TroubleDog54 <115918107+TroubleDog54@users.noreply.github.com> Date: Tue, 23 Jan 2024 18:23:53 +1100 Subject: [PATCH 05/18] docs: fix typo in the "Getting Started" post (#1502) --- _posts/2019-08-09-getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2019-08-09-getting-started.md b/_posts/2019-08-09-getting-started.md index 57026ee..a411dbc 100644 --- a/_posts/2019-08-09-getting-started.md +++ b/_posts/2019-08-09-getting-started.md @@ -101,7 +101,7 @@ Now you can choose _ONE_ of the following methods to deploy your Jekyll site. There are a few things to get ready for. - If you're on the GitHub Free plan, keep your site repository public. -- If you have committed `Gemfile.lock`{: .filepath} to the repository, and your local machine is not running Linux, go the the root of your site and update the platform list of the lock-file: +- If you have committed `Gemfile.lock`{: .filepath} to the repository, and your local machine is not running Linux, go to the root of your site and update the platform list of the lock-file: ```console $ bundle lock --add-platform x86_64-linux From 1127c43823aac4db7fd80d5bb706ae7b1e129dc6 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sun, 28 Jan 2024 02:22:33 +0800 Subject: [PATCH 06/18] feat: add `pwa.cache.*` option to precisely control caching (#1501) --- .gitignore | 2 + _config.yml | 17 +++--- _data/origin/cors.yml | 2 + _includes/favicons.html | 4 +- _includes/head.html | 9 ++++ _includes/js-selector.html | 8 +-- _javascript/pwa/app.js | 58 +++++++++++++++++++++ _javascript/pwa/sw.js | 101 ++++++++++++++++++++++++++++++++++++ assets/js/data/swcache.js | 49 ----------------- assets/js/data/swconf.js | 51 ++++++++++++++++++ assets/js/pwa/app.js | 47 ----------------- assets/js/pwa/sw.js | 89 ------------------------------- assets/js/pwa/unregister.js | 12 ----- jekyll-theme-chirpy.gemspec | 2 +- package.json | 4 +- rollup.config.js | 26 +++++++--- tools/init | 2 +- tools/release | 17 +++--- 18 files changed, 272 insertions(+), 228 deletions(-) create mode 100644 _javascript/pwa/app.js create mode 100644 _javascript/pwa/sw.js delete mode 100644 assets/js/data/swcache.js create mode 100644 assets/js/data/swconf.js delete mode 100644 assets/js/pwa/app.js delete mode 100644 assets/js/pwa/sw.js delete mode 100644 assets/js/pwa/unregister.js diff --git a/.gitignore b/.gitignore index cee9e12..3fdfa27 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,6 @@ package-lock.json .idea # Misc +*.map +sw.min.js assets/js/dist diff --git a/_config.yml b/_config.yml index 4ab1726..341e45d 100644 --- a/_config.yml +++ b/_config.yml @@ -63,7 +63,7 @@ google_analytics: # light - Use the light color scheme # dark - Use the dark color scheme # -theme_mode: # [light|dark] +theme_mode: # [light | dark] # The CDN endpoint for images. # Notice that once it is assigned, the CDN url @@ -108,10 +108,17 @@ assets: enabled: # boolean, keep empty means false # specify the Jekyll environment, empty means both # only works if `assets.self_host.enabled` is 'true' - env: # [development|production] + env: # [development | production] pwa: - enabled: true # the option for PWA feature + enabled: true # the option for PWA feature (installable) + cache: + enabled: true # the option for PWA offline cache + # Paths defined here will be excluded from the PWA cache. + # Usually its value is the `baseurl` of another website that + # shares the same domain name as the current website. + deny_paths: + # - "/example" # URLs match `/example/*` will not be cached by the PWA paginate: 10 @@ -157,10 +164,6 @@ defaults: values: layout: page permalink: /:title/ - - scope: - path: assets/img/favicons - values: - swcache: true - scope: path: assets/js/dist values: diff --git a/_data/origin/cors.yml b/_data/origin/cors.yml index 672df08..c2f65e9 100644 --- a/_data/origin/cors.yml +++ b/_data/origin/cors.yml @@ -8,6 +8,8 @@ cdns: - url: https://fonts.googleapis.com # jsDelivr CDN - url: https://cdn.jsdelivr.net + # polyfill.io for math + - url: https://polyfill.io # fonts diff --git a/_includes/favicons.html b/_includes/favicons.html index 201f6d8..957c933 100644 --- a/_includes/favicons.html +++ b/_includes/favicons.html @@ -8,7 +8,9 @@ - +{% if site.pwa.enabled %} + +{% endif %} diff --git a/_includes/head.html b/_includes/head.html index 70a33bd..a6fc255 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -45,6 +45,15 @@ {{ seo_tags }} + + + {%- unless page.layout == 'home' -%} {{ page.title | append: ' | ' }} diff --git a/_includes/js-selector.html b/_includes/js-selector.html index 6352c96..3515106 100644 --- a/_includes/js-selector.html +++ b/_includes/js-selector.html @@ -11,6 +11,8 @@ <!-- layout specified --> +{% assign js_dist = '/assets/js/dist/' %} + {% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %} {% assign urls = urls | append: ',' | append: site.data.origin[type]['lazy-polyfill'].js %} @@ -65,7 +67,7 @@ {% assign js = 'commons' %} {% endcase %} -{% capture script %}/assets/js/dist/{{ js }}.min.js{% endcapture %} +{% capture script %}{{ js_dist }}{{ js }}.min.js{% endcapture %} <script defer src="{{ script | relative_url }}"></script> {% if page.math %} @@ -94,9 +96,7 @@ {% if jekyll.environment == 'production' %} <!-- PWA --> {% if site.pwa.enabled %} - <script defer src="{{ '/app.js' | relative_url }}"></script> - {% else %} - <script defer src="{{ '/unregister.js' | relative_url }}"></script> + <script defer src="{{ 'app.min.js' | prepend: js_dist | relative_url }}"></script> {% endif %} <!-- GA --> diff --git a/_javascript/pwa/app.js b/_javascript/pwa/app.js new file mode 100644 index 0000000..5add2d7 --- /dev/null +++ b/_javascript/pwa/app.js @@ -0,0 +1,58 @@ +/* PWA loader */ + +if ('serviceWorker' in navigator) { + const meta = document.querySelector('meta[name="pwa-cache"]'); + const isEnabled = meta.content === 'true'; + + if (isEnabled) { + let swUrl = '/sw.min.js'; + const baseUrl = meta.getAttribute('data-baseurl'); + + if (baseUrl !== null) { + swUrl = `${baseUrl}${swUrl}?baseurl=${encodeURIComponent(baseUrl)}`; + } + + const $notification = $('#notification'); + const $btnRefresh = $('#notification .toast-body>button'); + + navigator.serviceWorker.register(swUrl).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'); + } + } + }); + }); + + $btnRefresh.on('click', () => { + if (registration.waiting) { + registration.waiting.postMessage('SKIP_WAITING'); + } + $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; + } + }); + } else { + navigator.serviceWorker.getRegistrations().then(function (registrations) { + for (let registration of registrations) { + registration.unregister(); + } + }); + } +} diff --git a/_javascript/pwa/sw.js b/_javascript/pwa/sw.js new file mode 100644 index 0000000..cb2bdef --- /dev/null +++ b/_javascript/pwa/sw.js @@ -0,0 +1,101 @@ +/* PWA service worker */ + +const swconfPath = '/assets/js/data/swconf.js'; +const params = new URL(location).searchParams; +const swconfUrl = params.has('baseurl') + ? `${params.get('baseurl')}${swconfPath}` + : swconfPath; + +importScripts(swconfUrl); +const purge = swconf.purge; + +function verifyHost(url) { + for (const host of swconf.allowHosts) { + const regex = RegExp(`^http(s)?://${host}/`); + if (regex.test(url)) { + return true; + } + } + return false; +} + +function verifyUrl(url) { + if (!verifyHost(url)) { + return false; + } + + const requestPath = new URL(url).pathname; + + for (const path of swconf.denyPaths) { + if (requestPath.startsWith(path)) { + return false; + } + } + return true; +} + +if (!purge) { + swconf.allowHosts.push(location.host); +} + +self.addEventListener('install', (event) => { + if (purge) { + return; + } + + event.waitUntil( + caches.open(swconf.cacheName).then((cache) => { + return cache.addAll(swconf.resources); + }) + ); +}); + +self.addEventListener('activate', (event) => { + event.waitUntil( + caches.keys().then((keyList) => { + return Promise.all( + keyList.map((key) => { + if (purge) { + return caches.delete(key); + } else { + if (key !== swconf.cacheName) { + return caches.delete(key); + } + } + }) + ); + }) + ); +}); + +self.addEventListener('message', (event) => { + if (event.data === 'SKIP_WAITING') { + self.skipWaiting(); + } +}); + +self.addEventListener('fetch', (event) => { + event.respondWith( + caches.match(event.request).then((response) => { + if (response) { + return response; + } + + return fetch(event.request).then((response) => { + const url = event.request.url; + + if (purge || event.request.method !== 'GET' || !verifyUrl(url)) { + return response; + } + + // See : <https://developers.google.com/web/fundamentals/primers/service-workers#cache_and_return_requests> + let responseToCache = response.clone(); + + caches.open(swconf.cacheName).then((cache) => { + cache.put(event.request, responseToCache); + }); + return response; + }); + }) + ); +}); diff --git a/assets/js/data/swcache.js b/assets/js/data/swcache.js deleted file mode 100644 index ed5d40e..0000000 --- a/assets/js/data/swcache.js +++ /dev/null @@ -1,49 +0,0 @@ ---- -layout: compress -# The list to be cached by PWA ---- - -const resource = [ - /* --- CSS --- */ - '{{ "/assets/css/:THEME.css" | replace: ':THEME', site.theme | relative_url }}', - - /* --- PWA --- */ - '{{ "/app.js" | relative_url }}', - '{{ "/sw.js" | 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 %} -]; - -/* 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 %} - - '{{ site.url | split: "//" | last }}', - - {% 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' -]; - -/* Requests that include the following path will be banned */ -const denyUrls = []; diff --git a/assets/js/data/swconf.js b/assets/js/data/swconf.js new file mode 100644 index 0000000..cc11f79 --- /dev/null +++ b/assets/js/data/swconf.js @@ -0,0 +1,51 @@ +--- +layout: compress +permalink: '/:path/swconf.js' +# Note that this file will be fetched by the ServiceWorker, so it will not be cached. +--- + +const swconf = { + {% if site.pwa.cache.enabled %} + cacheName: 'chirpy-{{ "now" | date: "%s" }}', + + {%- comment -%} Resources added to the cache during PWA installation. {%- endcomment -%} + resources: [ + '{{ "/assets/css/:THEME.css" | replace: ':THEME', site.theme | relative_url }}', + '{{ "/" | relative_url }}', + {% for tab in site.tabs %} + '{{- tab.url | relative_url -}}', + {% endfor %} + + {% assign cache_list = site.static_files | where: 'swcache', true %} + {% for file in cache_list %} + '{{ file.path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%} + {% endfor %} + ], + + {%- comment -%} The request url with below domain will be cached. {%- endcomment -%} + allowHosts: [ + {% if site.img_cdn and site.img_cdn contains '//' %} + '{{ site.img_cdn | split: '//' | last | split: '/' | first }}', + {% endif %} + + {%- unless site.assets.self_host.enabled -%} + {% for cdn in site.data.origin["cors"].cdns %} + '{{ cdn.url | split: "//" | last }}' + {%- unless forloop.last -%},{%- endunless -%} + {% endfor %} + {% endunless %} + ], + + {%- comment -%} The request url with below path will not be cached. {%- endcomment -%} + denyPaths: [ + {% for path in site.pwa.cache.deny_paths %} + {% unless path == empty %} + '{{ path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%} + {% endunless %} + {% endfor %} + ], + purge: false + {% else %} + purge: true + {% endif %} +}; diff --git a/assets/js/pwa/app.js b/assets/js/pwa/app.js deleted file mode 100644 index c798fe2..0000000 --- a/assets/js/pwa/app.js +++ /dev/null @@ -1,47 +0,0 @@ ---- -layout: compress -permalink: '/app.js' ---- - -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 => { - - /* 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'); - }); - }); - - 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 deleted file mode 100644 index 7e37234..0000000 --- a/assets/js/pwa/sw.js +++ /dev/null @@ -1,89 +0,0 @@ ---- -layout: compress -permalink: '/sw.js' -# PWA service worker ---- - -self.importScripts('{{ "/assets/js/data/swcache.js" | relative_url }}'); - -const cacheName = 'chirpy-{{ "now" | date: "%s" }}'; - -function verifyDomain(url) { - for (const domain of allowedDomains) { - const regex = RegExp(`^http(s)?:\/\/${domain}\/`); - if (regex.test(url)) { - return true; - } - } - - return false; -} - -function isExcluded(url) { - for (const item of denyUrls) { - if (url === item) { - return true; - } - } - return false; -} - -self.addEventListener('install', (event) => { - 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); - } - }) - ); - }) - ); -}); - -self.addEventListener('message', (event) => { - if (event.data === 'SKIP_WAITING') { - self.skipWaiting(); - } -}); - -self.addEventListener('fetch', (event) => { - event.respondWith( - caches.match(event.request).then((response) => { - if (response) { - return response; - } - - return fetch(event.request).then((response) => { - const url = event.request.url; - - 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(); - - caches.open(cacheName).then((cache) => { - /* console.log('[sw] Caching new resource: ' + event.request.url); */ - cache.put(event.request, responseToCache); - }); - - return response; - }); - }) - ); -}); diff --git a/assets/js/pwa/unregister.js b/assets/js/pwa/unregister.js deleted file mode 100644 index bd91150..0000000 --- a/assets/js/pwa/unregister.js +++ /dev/null @@ -1,12 +0,0 @@ ---- -layout: compress -permalink: '/unregister.js' ---- - -if ('serviceWorker' in navigator) { - navigator.serviceWorker.getRegistrations().then((registrations) => { - for (let reg of registrations) { - reg.unregister(); - } - }); -} diff --git a/jekyll-theme-chirpy.gemspec b/jekyll-theme-chirpy.gemspec index 2f01881..d1898cd 100644 --- a/jekyll-theme-chirpy.gemspec +++ b/jekyll-theme-chirpy.gemspec @@ -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\/(locales|origin)))|assets)\/|README|LICENSE)!i) + f.match(%r!^((_(includes|layouts|sass|(data\/(locales|origin)))|assets)\/|sw|README|LICENSE)!i) } spec.metadata = { diff --git a/package.json b/package.json index 334a506..eaa1c55 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,9 @@ }, "homepage": "https://github.com/cotes2020/jekyll-theme-chirpy/", "scripts": { - "prebuild": "npx rimraf assets/js/dist", + "prebuild": "npx rimraf assets/js/dist sw.min.js*", "build": "NODE_ENV=production npx rollup -c --bundleConfigAsCjs", - "prewatch": "npx rimraf assets/js/dist", + "prewatch": "npx rimraf assets/js/dist sw.min.js*", "watch": "npx rollup -c --bundleConfigAsCjs -w", "test": "npx stylelint _sass/**/*.scss", "fixlint": "npm run test -- --fix" diff --git a/rollup.config.js b/rollup.config.js index 907ca3e..1aee2b8 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -3,21 +3,29 @@ import terser from '@rollup/plugin-terser'; import license from 'rollup-plugin-license'; import path from 'path'; -const JS_SRC = '_javascript'; -const JS_DIST = 'assets/js/dist'; +const SRC_DEFAULT = '_javascript'; +const DIST_DEFAULT = 'assets/js/dist'; const isProd = process.env.NODE_ENV === 'production'; -function build(filename) { +function build(filename, opts) { + let src = SRC_DEFAULT; + let dist = DIST_DEFAULT; + + if (typeof opts !== 'undefined') { + src = opts.src || src; + dist = opts.dist || dist; + } + return { - input: [`${JS_SRC}/${filename}.js`], + input: [`${src}/${filename}.js`], output: { - file: `${JS_DIST}/${filename}.min.js`, + file: `${dist}/${filename}.min.js`, format: 'iife', name: 'Chirpy', sourcemap: !isProd }, watch: { - include: `${JS_SRC}/**` + include: `${src}/**` }, plugins: [ babel({ @@ -28,7 +36,7 @@ function build(filename) { license({ banner: { commentStyle: 'ignored', - content: { file: path.join(__dirname, JS_SRC, '_copyright') } + content: { file: path.join(__dirname, SRC_DEFAULT, '_copyright') } } }), isProd && terser() @@ -42,5 +50,7 @@ export default [ build('categories'), build('page'), build('post'), - build('misc') + build('misc'), + build('app', { src: `${SRC_DEFAULT}/pwa` }), + build('sw', { src: `${SRC_DEFAULT}/pwa`, dist: '.' }) ]; diff --git a/tools/init b/tools/init index 5baac5d..d8c7059 100755 --- a/tools/init +++ b/tools/init @@ -103,7 +103,7 @@ init_files() { npm i && npm run build # track the js output - _sedi "/^assets.*\/dist/d" .gitignore + _sedi "/^assets.*\/dist/d;/^sw.*\.js/d" .gitignore } commit() { diff --git a/tools/release b/tools/release index 6b4cc37..771f697 100755 --- a/tools/release +++ b/tools/release @@ -27,6 +27,7 @@ NODE_CONFIG="package.json" CHANGE_LOG="docs/CHANGELOG.md" JS_DIST="assets/js/dist" +PWA_SW="sw.min.js" BACKUP_PATH="$(mktemp -d)" FILES=( @@ -70,12 +71,14 @@ _check_git() { exit 1 fi - if [[ $working_branch != "$DEFAULT_BRANCH" && - $working_branch != hotfix/* && - $working_branch != "$PROD_BRANCH" ]]; then - echo "> Abort: Please run on the default, release or patch branch." - exit 1 - fi + $opt_pre || ( + if [[ $working_branch != "$DEFAULT_BRANCH" && + $working_branch != hotfix/* && + $working_branch != "$PROD_BRANCH" ]]; then + echo "> Abort: Please run on the default, release or patch branch." + exit 1 + fi + ) } _check_src() { @@ -156,7 +159,7 @@ build_gem() { rm -f ./*.gem npm run build - git add "$JS_DIST" -f # add JS dist to gem + git add "$JS_DIST" "$PWA_SW" -f # add JS distribution files to gem gem build "$GEM_SPEC" cp "$JS_DIST"/* "$BACKUP_PATH" From 74f16623c9c4877ef36ac52e8b69c19d1d9a82ba Mon Sep 17 00:00:00 2001 From: bigsk1 <32640296+bigsk1@users.noreply.github.com> Date: Sat, 27 Jan 2024 13:53:54 -0800 Subject: [PATCH 07/18] fix: correct the Twitter Card in social share preview (#1498) --------- Co-authored-by: Cotes Chung <11371340+cotes2020@users.noreply.github.com> --- _includes/head.html | 15 ++++++++++----- _includes/img-url.html | 13 ++++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/_includes/head.html b/_includes/head.html index a6fc255..839af65 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -20,7 +20,7 @@ {% unless src contains '://' %} {%- capture img_url -%} - {% include img-url.html src=src img_path=page.img_path %} + {% include img-url.html src=src img_path=page.img_path absolute=true %} {%- endcapture -%} {%- capture old_url -%}{{ src | absolute_url }}{%- endcapture -%} @@ -31,15 +31,20 @@ {% elsif site.social_preview_image %} {%- capture img_url -%} - {% include img-url.html src=site.social_preview_image %} + {% include img-url.html src=site.social_preview_image absolute=true %} {%- endcapture -%} {%- capture og_image -%} <meta property="og:image" content="{{ img_url }}" /> {%- endcapture -%} - {% assign old_meta_clip = '<meta name="twitter:card"' %} - {% assign new_meta_clip = og_image | append: old_meta_clip %} + {%- capture twitter_image -%} + <meta property="twitter:card" content="summary_large_image" /> + <meta property="twitter:image" content="{{ img_url }}" /> + {%- endcapture -%} + + {% assign old_meta_clip = '<meta name="twitter:card" content="summary" />' %} + {% assign new_meta_clip = og_image | append: twitter_image %} {% assign seo_tags = seo_tags | replace: old_meta_clip, new_meta_clip %} {% endif %} @@ -85,7 +90,7 @@ {% endif %} <!-- Bootstrap --> - <link rel="stylesheet" href="{{ site.data.origin[type].bootstrap.css | relative_url}}"> + <link rel="stylesheet" href="{{ site.data.origin[type].bootstrap.css | relative_url }}"> <!-- Font Awesome --> <link rel="stylesheet" href="{{ site.data.origin[type].fontawesome.css | relative_url }}"> diff --git a/_includes/img-url.html b/_includes/img-url.html index 44a80af..c08e8b9 100644 --- a/_includes/img-url.html +++ b/_includes/img-url.html @@ -2,8 +2,9 @@ Generate image final URL based on `site.img_cdn`, `page.img_path` Arguments: - src - basic image path, required - img_path - relative path of image, optional + src - required, basic image path + img_path - optional, relative path of image + absolute - optional, boolean, if true, generate absolute URL Return: image URL @@ -14,7 +15,7 @@ {%- if url -%} {% unless url contains ':' %} {%- comment -%} CND URL {%- endcomment -%} - {% assign prefix = site.img_cdn | default: '' | relative_url %} + {% assign prefix = site.img_cdn | default: '' %} {%- comment -%} Add page image path prefix {%- endcomment -%} {% assign url = include.img_path | default: '' | append: '/' | append: url %} @@ -26,6 +27,12 @@ | replace: '//', '/' | replace: ':', ':/' %} + + {% if include.absolute %} + {% assign url = url | absolute_url %} + {% else %} + {% assign url = url | relative_url %} + {% endif %} {% endunless %} {%- endif -%} From bbbb66b489a3bf2b878947336fe894e8ea2ae3f5 Mon Sep 17 00:00:00 2001 From: yeonwlee <81205766+yeonwlee@users.noreply.github.com> Date: Tue, 30 Jan 2024 09:22:03 +0900 Subject: [PATCH 08/18] perf: allow TOC to start at heading 3 (#1512) --- _javascript/modules/components/toc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_javascript/modules/components/toc.js b/_javascript/modules/components/toc.js index bfb0c00..b397813 100644 --- a/_javascript/modules/components/toc.js +++ b/_javascript/modules/components/toc.js @@ -1,5 +1,5 @@ export function toc() { - if (document.querySelector('main h2')) { + if (document.querySelector('main h2, main h3')) { // see: https://github.com/tscanlin/tocbot#usage tocbot.init({ tocSelector: '#toc', From c13ec311636d5e057c6895e353e1c1a4e570f582 Mon Sep 17 00:00:00 2001 From: Piotr Held <pjheld@gmail.com> Date: Tue, 30 Jan 2024 20:44:19 +0100 Subject: [PATCH 09/18] perf: enable equation numbering in MathJax (#1520) If you place your equations inside $$\begin{equation}...\end{equation}$$ you will get MathJax equation numbering. As described here: https://docs.mathjax.org/en/latest/input/tex/eqnumbers.html BREAKING CHANGES: if you used \begin{equation} inside $$ you will get equation numbering which was not previously present. --- _includes/js-selector.html | 4 +++- _posts/2019-08-08-text-and-typography.md | 9 ++++++++- _posts/2019-08-08-write-a-new-post.md | 23 ++++++++++++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/_includes/js-selector.html b/_includes/js-selector.html index 3515106..0e7f6f4 100644 --- a/_includes/js-selector.html +++ b/_includes/js-selector.html @@ -85,7 +85,9 @@ displayMath: [ ['$$', '$$'], ['\\[', '\\]'] - ] + ], + /* equation numbering */ + tags: 'ams' } }; </script> diff --git a/_posts/2019-08-08-text-and-typography.md b/_posts/2019-08-08-text-and-typography.md index e2cf403..7bf569d 100644 --- a/_posts/2019-08-08-text-and-typography.md +++ b/_posts/2019-08-08-text-and-typography.md @@ -134,7 +134,14 @@ fi; The mathematics powered by [**MathJax**](https://www.mathjax.org/): -$$ \sum_{n=1}^\infty 1/n^2 = \frac{\pi^2}{6} $$ +$$ +\begin{equation} + \sum_{n=1}^\infty 1/n^2 = \frac{\pi^2}{6} + \label{eq:series} +\end{equation} +$$ + +We can reference the equation as \eqref{eq:series}. When $a \ne 0$, there are two solutions to $ax^2 + bx + c = 0$ and they are diff --git a/_posts/2019-08-08-write-a-new-post.md b/_posts/2019-08-08-write-a-new-post.md index 9240f05..86194ed 100644 --- a/_posts/2019-08-08-write-a-new-post.md +++ b/_posts/2019-08-08-write-a-new-post.md @@ -69,7 +69,6 @@ authors: [<author1_id>, <author2_id>] # for multiple entries --- ``` - Having said that, the key `author` can also identify multiple entries. > The benefit of reading the author information from the file `_data/authors.yml`{: .filepath } is that the page will have the meta tag `twitter:creator`, which enriches the [Twitter Cards](https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started#card-and-content-attribution) and is good for SEO. @@ -107,9 +106,11 @@ math: true --- ``` -After enabling the mathematical feature, you can add math equations with the following syntax: +After enabling the mathematical feature, you can add math equations with the following syntax: - **Block math** should be added with `$$ math $$` with **mandatory** blank lines before and after `$$` + - **Inserting equation numbering** should be added with `$$\begin{equation} math \end{equation}$$` + - **Referencing equation numbering** should be done with `\label{eq:label_name}` in the equation block and `\eqref{eq:label_name}` inline with text (see example below) - **Inline math** (in lines) should be added with `$$ math $$` without any blank line before or after `$$` - **Inline math** (in lists) should be added with `\$$ math $$` @@ -120,6 +121,17 @@ $$ LaTeX_math_expression $$ +<!-- Equation numbering, keep all blank lines --> + +$$ +\begin{equation} + LaTeX_math_expression + \label{eq:label_name} +\end{equation} +$$ + +Can be referenced as \eqref{eq:label_name}. + <!-- Inline math in lines, NO blank lines --> "Lorem ipsum dolor sit amet, $$ LaTeX_math_expression $$ consectetur adipiscing elit." @@ -243,7 +255,7 @@ For instance, when using images: The parsing result will automatically add the CDN prefix `https://cdn.com` before the image path: ```html -<img src="https://cdn.com/path/to/flower.png" alt="The flower"> +<img src="https://cdn.com/path/to/flower.png" alt="The flower" /> ``` {: .nolineno } @@ -267,7 +279,7 @@ And then, the image source of Markdown can write the file name directly: The output will be: ```html -<img src="/img/path/flower.png" alt="The flower"> +<img src="/img/path/flower.png" alt="The flower" /> ``` {: .nolineno } @@ -285,7 +297,7 @@ image: --- ``` -Note that the [`img_path`](#image-path) can also be passed to the preview image, that is, when it has been set, the attribute `path` only needs the image file name. +Note that the [`img_path`](#image-path) can also be passed to the preview image, that is, when it has been set, the attribute `path` only needs the image file name. For simple use, you can also just use `image` to define the path. @@ -420,6 +432,7 @@ You can embed a video with the following syntax: ```liquid {% include embed/{Platform}.html id='{ID}' %} ``` + Where `Platform` is the lowercase of the platform name, and `ID` is the video ID. The following table shows how to get the two parameters we need in a given video URL, and you can also know the currently supported video platforms. From f3ea7e988779f46e577e1ac7b29593c1ac1e5cbf Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Thu, 1 Feb 2024 01:07:46 +0800 Subject: [PATCH 10/18] build(security): improve paths filter for CodeQL --- .github/workflows/codeql.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index c194d8b..7abcfb1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,9 +2,9 @@ name: "CodeQL" on: push: - paths: ["**.js"] + paths: ["_javascript/**.js"] pull_request: - paths: ["**.js"] + paths: ["_javascript/**.js"] schedule: - cron: "0 0 * * 5" From c335bc6ce77a623298c5f005c693d36c8aa7ae27 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sat, 3 Feb 2024 18:53:35 +0800 Subject: [PATCH 11/18] build(security): stop scheduled scanning --- .github/workflows/codeql.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7abcfb1..1745fcf 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -5,8 +5,6 @@ on: paths: ["_javascript/**.js"] pull_request: paths: ["_javascript/**.js"] - schedule: - - cron: "0 0 * * 5" jobs: analyze: From 1a01c35e52bef2b801271e39cea6a9c46bb79c24 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Mon, 5 Feb 2024 07:28:35 +0800 Subject: [PATCH 12/18] chore: update stale-bot settings --- .github/workflows/stale.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 7edeb75..bcf425a 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -22,8 +22,8 @@ jobs: steps: - uses: actions/stale@v9 with: - days-before-stale: 30 - days-before-close: 1 + # 60 days before marking issues/PRs stale + days-before-close: -1 # does not close automatically stale-issue-label: ${{ env.STALE_LABEL }} exempt-issue-labels: ${{ env.EXEMPT_LABELS }} stale-issue-message: ${{ env.MESSAGE }} From 90693ff95e72ca4b5135a7b454a6ab521b995b3e Mon Sep 17 00:00:00 2001 From: Benjamin van den Hout <bvdhout@gmail.com> Date: Tue, 6 Feb 2024 15:19:28 +0100 Subject: [PATCH 13/18] feat: add analytics support for GoatCounter (#1526) --- README.md | 2 +- _config.yml | 3 +++ _includes/goatcounter.html | 8 ++++++++ _includes/js-selector.html | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 _includes/goatcounter.html diff --git a/README.md b/README.md index 16d6ab1..0e074cf 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ - Built-in Search - Atom Feeds - PWA -- Google Analytics +- Google Analytics / GoatCounter - SEO & Performance Optimization ## Documentation diff --git a/_config.yml b/_config.yml index 341e45d..79d451f 100644 --- a/_config.yml +++ b/_config.yml @@ -52,6 +52,9 @@ google_site_verification: # fill in to your verification string google_analytics: id: # fill in your Google Analytics ID +goatcounter: + id: # fill in your Goatcounter ID + # Prefer color scheme setting. # # Note: Keep empty will follow the system prefer color by default, diff --git a/_includes/goatcounter.html b/_includes/goatcounter.html new file mode 100644 index 0000000..4d21d21 --- /dev/null +++ b/_includes/goatcounter.html @@ -0,0 +1,8 @@ +<!-- GoatCounter --> + +<script + data-goatcounter="https://{{ site.goatcounter.id }}.goatcounter.com/count" + async + src="https://gc.zgo.at/count.js" +></script> + diff --git a/_includes/js-selector.html b/_includes/js-selector.html index 0e7f6f4..1a1fa58 100644 --- a/_includes/js-selector.html +++ b/_includes/js-selector.html @@ -105,4 +105,9 @@ {% if site.google_analytics.id != empty and site.google_analytics.id %} {% include google-analytics.html %} {% endif %} + + <!-- GoatCounter --> + {% if site.goatcounter.id != empty and site.goatcounter.id %} + {% include goatcounter.html %} + {% endif %} {% endif %} From 6b34901d94d7c9332accae7ab907ba77c4e247a1 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Tue, 13 Feb 2024 23:35:32 +0800 Subject: [PATCH 14/18] refactor(pwa): revert to JS and Liquid mixing The gem package won't be able to pass `/sw.min.js` to the user end --- .gitignore | 2 -- _includes/head.html | 9 --------- {_javascript => assets/js}/pwa/app.js | 20 ++++++++------------ {_javascript => assets/js}/pwa/sw.js | 14 +++++++------- jekyll-theme-chirpy.gemspec | 2 +- package.json | 4 ++-- rollup.config.js | 20 +++++--------------- tools/init | 2 +- tools/release | 3 +-- 9 files changed, 25 insertions(+), 51 deletions(-) rename {_javascript => assets/js}/pwa/app.js (73%) rename {_javascript => assets/js}/pwa/sw.js (84%) diff --git a/.gitignore b/.gitignore index 3fdfa27..cee9e12 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,4 @@ package-lock.json .idea # Misc -*.map -sw.min.js assets/js/dist diff --git a/_includes/head.html b/_includes/head.html index 839af65..9bad78a 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -50,15 +50,6 @@ {{ seo_tags }} - <!-- PWA cache settings --> - <meta - name="pwa-cache" - content="{{ site.pwa.cache.enabled | default: 'false' }}" - {%- if site.baseurl and site.baseurl != empty -%} - data-baseurl="{{ site.baseurl }}" - {%- endif -%} - > - <title> {%- unless page.layout == 'home' -%} {{ page.title | append: ' | ' }} diff --git a/_javascript/pwa/app.js b/assets/js/pwa/app.js similarity index 73% rename from _javascript/pwa/app.js rename to assets/js/pwa/app.js index 5add2d7..8599fe3 100644 --- a/_javascript/pwa/app.js +++ b/assets/js/pwa/app.js @@ -1,22 +1,18 @@ -/* PWA loader */ +--- +layout: compress +permalink: /assets/js/dist/:basename.min.js +--- if ('serviceWorker' in navigator) { - const meta = document.querySelector('meta[name="pwa-cache"]'); - const isEnabled = meta.content === 'true'; + const isEnabled = '{{ site.pwa.enabled }}' === 'true'; if (isEnabled) { - let swUrl = '/sw.min.js'; - const baseUrl = meta.getAttribute('data-baseurl'); - - if (baseUrl !== null) { - swUrl = `${baseUrl}${swUrl}?baseurl=${encodeURIComponent(baseUrl)}`; - } - + const swUrl = '{{ '/sw.min.js' | relative_url }}'; const $notification = $('#notification'); const $btnRefresh = $('#notification .toast-body>button'); navigator.serviceWorker.register(swUrl).then((registration) => { - // In case the user ignores the notification + {% comment %}In case the user ignores the notification{% endcomment %} if (registration.waiting) { $notification.toast('show'); } @@ -41,7 +37,7 @@ if ('serviceWorker' in navigator) { let refreshing = false; - // Detect controller change and refresh all the opened tabs + {% comment %}Detect controller change and refresh all the opened tabs{% endcomment %} navigator.serviceWorker.addEventListener('controllerchange', () => { if (!refreshing) { window.location.reload(); diff --git a/_javascript/pwa/sw.js b/assets/js/pwa/sw.js similarity index 84% rename from _javascript/pwa/sw.js rename to assets/js/pwa/sw.js index cb2bdef..adc707e 100644 --- a/_javascript/pwa/sw.js +++ b/assets/js/pwa/sw.js @@ -1,10 +1,10 @@ -/* PWA service worker */ +--- +layout: compress +permalink: /:basename.min.js +# PWA service worker +--- -const swconfPath = '/assets/js/data/swconf.js'; -const params = new URL(location).searchParams; -const swconfUrl = params.has('baseurl') - ? `${params.get('baseurl')}${swconfPath}` - : swconfPath; +const swconfUrl = '{{ '/assets/js/data/swconf.js' | relative_url }}'; importScripts(swconfUrl); const purge = swconf.purge; @@ -88,7 +88,7 @@ self.addEventListener('fetch', (event) => { return response; } - // See : <https://developers.google.com/web/fundamentals/primers/service-workers#cache_and_return_requests> + {% comment %}See: <https://developers.google.com/web/fundamentals/primers/service-workers#cache_and_return_requests>{% endcomment %} let responseToCache = response.clone(); caches.open(swconf.cacheName).then((cache) => { diff --git a/jekyll-theme-chirpy.gemspec b/jekyll-theme-chirpy.gemspec index d1898cd..2f01881 100644 --- a/jekyll-theme-chirpy.gemspec +++ b/jekyll-theme-chirpy.gemspec @@ -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\/(locales|origin)))|assets)\/|sw|README|LICENSE)!i) + f.match(%r!^((_(includes|layouts|sass|(data\/(locales|origin)))|assets)\/|README|LICENSE)!i) } spec.metadata = { diff --git a/package.json b/package.json index eaa1c55..334a506 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,9 @@ }, "homepage": "https://github.com/cotes2020/jekyll-theme-chirpy/", "scripts": { - "prebuild": "npx rimraf assets/js/dist sw.min.js*", + "prebuild": "npx rimraf assets/js/dist", "build": "NODE_ENV=production npx rollup -c --bundleConfigAsCjs", - "prewatch": "npx rimraf assets/js/dist sw.min.js*", + "prewatch": "npx rimraf assets/js/dist", "watch": "npx rollup -c --bundleConfigAsCjs -w", "test": "npx stylelint _sass/**/*.scss", "fixlint": "npm run test -- --fix" diff --git a/rollup.config.js b/rollup.config.js index 1aee2b8..7f2d14a 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -7,25 +7,17 @@ const SRC_DEFAULT = '_javascript'; const DIST_DEFAULT = 'assets/js/dist'; const isProd = process.env.NODE_ENV === 'production'; -function build(filename, opts) { - let src = SRC_DEFAULT; - let dist = DIST_DEFAULT; - - if (typeof opts !== 'undefined') { - src = opts.src || src; - dist = opts.dist || dist; - } - +function build(filename) { return { - input: [`${src}/${filename}.js`], + input: [`${SRC_DEFAULT}/${filename}.js`], output: { - file: `${dist}/${filename}.min.js`, + file: `${DIST_DEFAULT}/${filename}.min.js`, format: 'iife', name: 'Chirpy', sourcemap: !isProd }, watch: { - include: `${src}/**` + include: `${SRC_DEFAULT}/**` }, plugins: [ babel({ @@ -50,7 +42,5 @@ export default [ build('categories'), build('page'), build('post'), - build('misc'), - build('app', { src: `${SRC_DEFAULT}/pwa` }), - build('sw', { src: `${SRC_DEFAULT}/pwa`, dist: '.' }) + build('misc') ]; diff --git a/tools/init b/tools/init index d8c7059..5baac5d 100755 --- a/tools/init +++ b/tools/init @@ -103,7 +103,7 @@ init_files() { npm i && npm run build # track the js output - _sedi "/^assets.*\/dist/d;/^sw.*\.js/d" .gitignore + _sedi "/^assets.*\/dist/d" .gitignore } commit() { diff --git a/tools/release b/tools/release index 771f697..bb54a0b 100755 --- a/tools/release +++ b/tools/release @@ -27,7 +27,6 @@ NODE_CONFIG="package.json" CHANGE_LOG="docs/CHANGELOG.md" JS_DIST="assets/js/dist" -PWA_SW="sw.min.js" BACKUP_PATH="$(mktemp -d)" FILES=( @@ -159,7 +158,7 @@ build_gem() { rm -f ./*.gem npm run build - git add "$JS_DIST" "$PWA_SW" -f # add JS distribution files to gem + git add "$JS_DIST" -f # add JS distribution files to gem gem build "$GEM_SPEC" cp "$JS_DIST"/* "$BACKUP_PATH" From 79c65b3e44a9aa33197212802c3d2eb9e038df1f Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Wed, 14 Feb 2024 00:02:05 +0800 Subject: [PATCH 15/18] build(security): correct scan path for CodeQL --- .github/codeql/codeql-config.yml | 2 ++ .github/workflows/codeql.yml | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .github/codeql/codeql-config.yml diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 0000000..1439beb --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,2 @@ +paths-ignore: + - "assets/js" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1745fcf..b09590d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,9 +2,9 @@ name: "CodeQL" on: push: - paths: ["_javascript/**.js"] + paths: ["_javascript/**/*.js"] pull_request: - paths: ["_javascript/**.js"] + paths: ["_javascript/**/*.js"] jobs: analyze: @@ -30,6 +30,7 @@ jobs: uses: github/codeql-action/init@v3 with: languages: "${{ matrix.language }}" + config-file: .github/codeql/codeql-config.yml # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). # If this step fails, then you should remove it and run the build manually (see below) From 365abc6b3b0af43fd4e1bbc96c8b876c9c4fdc0a Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Wed, 14 Feb 2024 01:53:49 +0800 Subject: [PATCH 16/18] build(deps-dev): set update interval to weekly --- .github/dependabot.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index dd59389..bec1046 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,7 +7,7 @@ updates: bundler: dependency-type: "production" schedule: - interval: "monthly" + interval: "weekly" - package-ecosystem: "npm" directory: "/" versioning-strategy: increase @@ -15,7 +15,7 @@ updates: npm: dependency-type: "development" schedule: - interval: "monthly" + interval: "weekly" - package-ecosystem: "github-actions" directory: "/" groups: @@ -23,4 +23,4 @@ updates: update-types: - "major" schedule: - interval: "monthly" + interval: "weekly" From 6230d1d750120149c616a4e201942ef1e865464b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 00:12:45 +0800 Subject: [PATCH 17/18] build(deps-dev): bump the npm group with 8 updates (#1540) Updates the requirements on [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core), [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env), [@commitlint/cli](https://github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/cli), [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/config-conventional), [husky](https://github.com/typicode/husky), [rollup](https://github.com/rollup/rollup), [stylelint](https://github.com/stylelint/stylelint) and [stylelint-config-standard-scss](https://github.com/stylelint-scss/stylelint-config-standard-scss) to permit the latest version. Updates `@babel/core` to 7.23.9 - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.23.9/packages/babel-core) Updates `@babel/preset-env` to 7.23.9 - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.23.9/packages/babel-preset-env) Updates `@commitlint/cli` to 18.6.1 - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/cli/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/commits/v18.6.1/@commitlint/cli) Updates `@commitlint/config-conventional` to 18.6.2 - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/config-conventional/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/commits/v18.6.2/@commitlint/config-conventional) Updates `husky` from 8.0.3 to 9.0.11 - [Release notes](https://github.com/typicode/husky/releases) - [Commits](https://github.com/typicode/husky/compare/v8.0.3...v9.0.11) Updates `rollup` to 4.10.0 - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](https://github.com/rollup/rollup/compare/v4.9.2...v4.10.0) Updates `stylelint` to 16.2.1 - [Release notes](https://github.com/stylelint/stylelint/releases) - [Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md) - [Commits](https://github.com/stylelint/stylelint/compare/16.1.0...16.2.1) Updates `stylelint-config-standard-scss` from 12.0.0 to 13.0.0 - [Release notes](https://github.com/stylelint-scss/stylelint-config-standard-scss/releases) - [Changelog](https://github.com/stylelint-scss/stylelint-config-standard-scss/blob/main/CHANGELOG.md) - [Commits](https://github.com/stylelint-scss/stylelint-config-standard-scss/compare/v12.0.0...v13.0.0) --- updated-dependencies: - dependency-name: "@babel/core" dependency-type: direct:development dependency-group: npm - dependency-name: "@babel/preset-env" dependency-type: direct:development dependency-group: npm - dependency-name: "@commitlint/cli" dependency-type: direct:development dependency-group: npm - dependency-name: "@commitlint/config-conventional" dependency-type: direct:development dependency-group: npm - dependency-name: husky dependency-type: direct:development update-type: version-update:semver-major dependency-group: npm - dependency-name: rollup dependency-type: direct:development dependency-group: npm - dependency-name: stylelint dependency-type: direct:development dependency-group: npm - dependency-name: stylelint-config-standard-scss dependency-type: direct:development update-type: version-update:semver-major dependency-group: npm ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 334a506..eb3af70 100644 --- a/package.json +++ b/package.json @@ -21,19 +21,19 @@ "fixlint": "npm run test -- --fix" }, "devDependencies": { - "@babel/core": "^7.23.7", + "@babel/core": "^7.23.9", "@babel/plugin-proposal-class-properties": "^7.18.6", - "@babel/preset-env": "^7.23.7", - "@commitlint/cli": "^18.4.4", - "@commitlint/config-conventional": "^18.4.4", + "@babel/preset-env": "^7.23.9", + "@commitlint/cli": "^18.6.1", + "@commitlint/config-conventional": "^18.6.2", "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-terser": "^0.4.4", - "husky": "^8.0.3", + "husky": "^9.0.11", "rimraf": "^5.0.5", - "rollup": "^4.9.2", + "rollup": "^4.10.0", "rollup-plugin-license": "^3.2.0", - "stylelint": "^16.1.0", - "stylelint-config-standard-scss": "^12.0.0" + "stylelint": "^16.2.1", + "stylelint-config-standard-scss": "^13.0.0" }, "prettier": { "trailingComma": "none" From cd258c92c34efd0fcbc43c88065bb75aff00f6a8 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Thu, 15 Feb 2024 00:18:09 +0800 Subject: [PATCH 18/18] chore(deps): upgrade mermaid to `10.8.0` --- _data/origin/cors.yml | 2 +- assets/lib | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_data/origin/cors.yml b/_data/origin/cors.yml index c2f65e9..5be89c1 100644 --- a/_data/origin/cors.yml +++ b/_data/origin/cors.yml @@ -35,7 +35,7 @@ search: js: https://cdn.jsdelivr.net/npm/simple-jekyll-search@1.10.0/dest/simple-jekyll-search.min.js mermaid: - js: https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js + js: https://cdn.jsdelivr.net/npm/mermaid@10.8.0/dist/mermaid.min.js dayjs: js: diff --git a/assets/lib b/assets/lib index c577249..7bc0d86 160000 --- a/assets/lib +++ b/assets/lib @@ -1 +1 @@ -Subproject commit c57724981c36d839881f89540d34d205db06a86f +Subproject commit 7bc0d86b6af83d7acfc63db50f29a5975cec2513