From f03c44d7fea815e3ef646f913975f4da5b3116ed Mon Sep 17 00:00:00 2001
From: neveler <55753029+neveler@users.noreply.github.com>
Date: Fri, 5 Jun 2026 09:38:03 +0800
Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9E=84=E5=BB=BA?=
=?UTF-8?q?=E9=95=9C=E5=83=8F=E4=B8=BA=20`cimg/ruby:3.4.9-node`?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.drone.yml | 9 ++++++++-
.gitignore | 24 ++++++++++++++++-------
Gemfile | 3 +--
_config.yml | 5 +++++
_plugins/kramdown_enhancer.rb | 19 +++++++++++-------
_plugins/node.rb | 23 ++++++++++++++++++++++
_plugins/post_process.rb | 8 +++-----
_plugins/vendor/kramdown_enhancer/webp.ts | 22 +++++++++++++++++++++
package.json | 10 ++++++++++
9 files changed, 101 insertions(+), 22 deletions(-)
create mode 100644 _plugins/node.rb
create mode 100644 _plugins/vendor/kramdown_enhancer/webp.ts
create mode 100644 package.json
diff --git a/.drone.yml b/.drone.yml
index 7f16f3c1..2ee2533a 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -7,11 +7,13 @@ clone:
steps:
- name: build
- image: ruby:3.4
+ image: cimg/ruby:3.4.9-node
environment:
JEKYLL_ENV: production
BUNDLE_PATH: vendor/bundle
commands:
+ - npm config set registry http://mirrors.cloud.tencent.com/npm
+ - npm install
- bundle config mirror.https://rubygems.org https://mirrors.cloud.tencent.com/rubygems
- bundle install --verbose
- bundle exec jekyll build --trace --verbose
@@ -22,6 +24,8 @@ steps:
path: /drone/src/vendor
- name: jekyll-cache
path: /drone/src/.jekyll-cache
+ - name: node_modules
+ path: /drone/src/node_modules
when:
branch: [main]
@@ -35,3 +39,6 @@ volumes:
- name: jekyll-cache
host:
path: /home/ubuntu/docs.hmcl.net/cache/jekyll-cache
+- name: node_modules
+ host:
+ path: /home/ubuntu/docs.hmcl.net/cache/node_modules
diff --git a/.gitignore b/.gitignore
index f60b43ac..4b2e8308 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,18 @@
-_site
-.sass-cache
-.jekyll-cache
-.jekyll-metadata
-vendor
-Gemfile.lock
+.sass-cache/
+.jekyll-cache/
+.jekyll-metadata/
+
+/.idea/
+
+/_site/
+
+/vendor/
+/node_modules/
+
.bundle
-/.idea/
\ No newline at end of file
+
+/Gemfile.lock
+/package-lock.json
+/yarn.lock
+/pnpm-lock.yaml
+/bun.lock
diff --git a/Gemfile b/Gemfile
index e4e9405f..a9a57635 100644
--- a/Gemfile
+++ b/Gemfile
@@ -32,6 +32,5 @@ gem "wdm", "0.2.0", :platforms => [:windows]
gem "http_parser.rb", "0.8.0", :platforms => [:jruby]
# plugin dependencies
-gem "webp-ffi", "0.4.0" if ENV["ENABLE_WEBP_AUTO_CONVERSION"] == "true" || ENV["DRONE"] == "true"
-gem "mini_racer", "0.20.0" if ENV["ENABLE_EMBEDDED_V8"] == "true" || ENV["DRONE"] == "true"
gem "terser", "1.2.7"
+gem "open3", "0.2.1"
diff --git a/_config.yml b/_config.yml
index e76e9a43..cc7a6d49 100644
--- a/_config.yml
+++ b/_config.yml
@@ -50,6 +50,11 @@ include:
exclude:
- README.md
- LICENSE
+ - package.json
+ - package-lock.json
+ - yarn.lock
+ - pnpm-lock.yaml
+ - bun.lock
keep_files: []
encoding: "utf-8"
# markdown_ext: "markdown,mkdown,mkdn,mkd,md"
diff --git a/_plugins/kramdown_enhancer.rb b/_plugins/kramdown_enhancer.rb
index 5ad64746..a85e5c6f 100644
--- a/_plugins/kramdown_enhancer.rb
+++ b/_plugins/kramdown_enhancer.rb
@@ -1,7 +1,3 @@
-begin
- require "webp-ffi"
-rescue LoadError; end
-
module KramdownEnhancer
GITHUB_LINK_REGEX = /\b(GP-\d+|GC-[0-9a-f]{7})\b/
BLOCKQUOTE_TYPES = {
@@ -36,6 +32,16 @@ def baseurl=(input)
end
end
+ class WebP
+ class << self
+ def encode(source, destination)
+ stdout, stderr, status = Node::run("_plugins/vendor/kramdown_enhancer/webp.ts", source, destination)
+ raise stderr unless status.success?
+ Jekyll.logger.info "KramdownEnhancer:", "[webp] Generated #{stdout}"
+ end
+ end
+ end
+
class WebpFile < Jekyll::StaticFile
def write(dest)
true
@@ -173,7 +179,6 @@ def relative_url(input)
Jekyll::Hooks.register :site, :post_read do |site|
KramdownEnhancer.baseurl = site.config["baseurl"]
webp_list = []
- webp_enabled = defined?(WebP)
site.each_site_file do |file|
KramdownEnhancer.file[file.relative_path] = file
if file.is_a?(Jekyll::StaticFile)
@@ -182,9 +187,9 @@ def relative_url(input)
destination = File.join(site.dest, url)
if File.exist?(source)
KramdownEnhancer.webp[file.url] = url
- elsif webp_enabled && %w[.png .jpg .jpeg .tif .tiff].include?(file.extname.downcase)
+ elsif %w[.png .jpg .jpeg .tif .tiff].include?(file.extname.downcase)
FileUtils.mkdir_p(File.dirname(destination))
- WebP.encode(file.path, destination)
+ KramdownEnhancer::WebP.encode(file.path, destination)
webp_list.push(KramdownEnhancer::WebpFile.new(site, site.dest, File.dirname(url), File.basename(url)))
KramdownEnhancer.webp[file.url] = url
end
diff --git a/_plugins/node.rb b/_plugins/node.rb
new file mode 100644
index 00000000..99670aa0
--- /dev/null
+++ b/_plugins/node.rb
@@ -0,0 +1,23 @@
+require "open3"
+
+module Node
+ class << self
+ def initialize()
+ _, _, status = Open3.capture3("bun", "-v")
+ if status.success?
+ @runtime = "bun"
+ end
+ _, stderr, status = Open3.capture3("node", "-v")
+ raise stderr unless status.success?
+ @runtime = "node"
+ end
+
+ def run(*args)
+ if @runtime == "bun"
+ Open3.capture3("bun", "run", *args)
+ else
+ Open3.capture3("node", *args)
+ end
+ end
+ end
+end
diff --git a/_plugins/post_process.rb b/_plugins/post_process.rb
index 396a83c7..62fb6ec5 100644
--- a/_plugins/post_process.rb
+++ b/_plugins/post_process.rb
@@ -1,7 +1,5 @@
require "terser"
-ExecJS.runtime = ExecJS::Runtimes::MiniRacer if ExecJS::Runtimes::MiniRacer.available?
-
Jekyll::Hooks.register :site, :post_write do |site|
config = site.config["post_process"]
next unless config
@@ -26,7 +24,7 @@
if terser_inputs_all_exist
destination = File.join(site.dest, terser_output.to_s)
File.write(destination, Terser.compile(terser_codes.join(";")))
- Jekyll.logger.info "Post Process:", "terser #{terser_output}"
+ Jekyll.logger.info "Post Process:", "[terser] #{terser_output}"
end
end
end
@@ -36,7 +34,7 @@
remove_files.each do |file|
destination = File.join(site.dest, file)
File.delete(destination) if File.exist?(destination)
- Jekyll.logger.info "Post Process:", "remove_files #{file}"
+ Jekyll.logger.info "Post Process:", "[remove_files] #{file}"
end
end
@@ -45,7 +43,7 @@
remove_dirs.each do |dir|
destination = File.join(site.dest, dir)
FileUtils.rm_rf(destination) if File.directory?(destination)
- Jekyll.logger.info "Post Process:", "remove_dirs #{dir}"
+ Jekyll.logger.info "Post Process:", "[remove_dirs] #{dir}"
end
end
end
diff --git a/_plugins/vendor/kramdown_enhancer/webp.ts b/_plugins/vendor/kramdown_enhancer/webp.ts
new file mode 100644
index 00000000..1a5d1d7f
--- /dev/null
+++ b/_plugins/vendor/kramdown_enhancer/webp.ts
@@ -0,0 +1,22 @@
+import fs from "fs";
+import path from "path";
+import sharp from "sharp";
+
+const [source, destination] = process.argv.slice(2);
+
+if (source === undefined || destination === undefined) {
+ throw new Error("param error");
+}
+
+if (!fs.existsSync(source)) {
+ throw new Error("source not exist");
+}
+
+const pwd = process.cwd();
+
+sharp(source).toFile(destination, (err) => {
+ if (err) {
+ throw err;
+ }
+ console.log(path.relative(pwd, destination));
+});
diff --git a/package.json b/package.json
new file mode 100644
index 00000000..46a8140d
--- /dev/null
+++ b/package.json
@@ -0,0 +1,10 @@
+{
+ "type": "module",
+ "dependencies": {
+ "sharp": "0.34.5"
+ },
+ "devDependencies": {
+ "@types/node": "25.9.1",
+ "typescript": "6.0.3"
+ }
+}
\ No newline at end of file
From 899bd7d38efa2f8cfdb2a47a04104e70ab3c00b8 Mon Sep 17 00:00:00 2001
From: neveler <55753029+neveler@users.noreply.github.com>
Date: Fri, 5 Jun 2026 09:50:02 +0800
Subject: [PATCH 2/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20PR=20Preview?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.github/workflows/pr-preview.yml | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml
index 99cae981..afa036ff 100644
--- a/.github/workflows/pr-preview.yml
+++ b/.github/workflows/pr-preview.yml
@@ -225,12 +225,14 @@ jobs:
git fetch https://github.com/${{ needs.preview-create-init.outputs.repository }} ${{ needs.preview-create-init.outputs.sha }}
git merge --squash ${{ needs.preview-create-init.outputs.sha }} --no-edit
git commit -m "Merge #${{ env.GITHUB_PR_NUMBER }} for preview build"
+ - name: Setup node
+ uses: actions/setup-node@v6
+ with:
+ node-version: 24
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
- bundler-cache: ${{ env.PREVIEW_WATCH }}
- cache-version: PR-${{ env.GITHUB_PR_NUMBER }}
- name: Jekyll Build
run: |
echo "url: https://${{ needs.preview-create-init.outputs.domain }}" > _action.yml
@@ -239,7 +241,7 @@ jobs:
echo "destination: /home/runner/site" >> _action.yml
echo "preview:" >> _action.yml
echo " pr-number: ${{ env.GITHUB_PR_NUMBER }}" >> _action.yml
- ${{ env.PREVIEW_WATCH }} || bundle install --jobs 4
+ npm install && bundle install --jobs 4
bundle exec jekyll build --trace --config _config.yml,_action.yml
- id: upload-site
name: Upload Site
From df5480f86638cf3360cda14f26341f6b0afd1ac3 Mon Sep 17 00:00:00 2001
From: neveler <55753029+neveler@users.noreply.github.com>
Date: Fri, 5 Jun 2026 10:09:20 +0800
Subject: [PATCH 3/7] update
---
_plugins/kramdown_enhancer.rb | 2 +-
.../webp.ts => kramdown_enhancer/webp.js} | 0
_plugins/node.rb | 10 ++++++----
3 files changed, 7 insertions(+), 5 deletions(-)
rename _plugins/{vendor/kramdown_enhancer/webp.ts => kramdown_enhancer/webp.js} (100%)
diff --git a/_plugins/kramdown_enhancer.rb b/_plugins/kramdown_enhancer.rb
index a85e5c6f..02406a7b 100644
--- a/_plugins/kramdown_enhancer.rb
+++ b/_plugins/kramdown_enhancer.rb
@@ -35,7 +35,7 @@ def baseurl=(input)
class WebP
class << self
def encode(source, destination)
- stdout, stderr, status = Node::run("_plugins/vendor/kramdown_enhancer/webp.ts", source, destination)
+ stdout, stderr, status = Node::run("_plugins/kramdown_enhancer/webp.js", source, destination)
raise stderr unless status.success?
Jekyll.logger.info "KramdownEnhancer:", "[webp] Generated #{stdout}"
end
diff --git a/_plugins/vendor/kramdown_enhancer/webp.ts b/_plugins/kramdown_enhancer/webp.js
similarity index 100%
rename from _plugins/vendor/kramdown_enhancer/webp.ts
rename to _plugins/kramdown_enhancer/webp.js
diff --git a/_plugins/node.rb b/_plugins/node.rb
index 99670aa0..0eab2f15 100644
--- a/_plugins/node.rb
+++ b/_plugins/node.rb
@@ -2,14 +2,16 @@
module Node
class << self
- def initialize()
+ def initialize
_, _, status = Open3.capture3("bun", "-v")
if status.success?
@runtime = "bun"
+ else
+ _, stderr, status = Open3.capture3("node", "-v")
+ raise stderr unless status.success?
+ @runtime = "node"
end
- _, stderr, status = Open3.capture3("node", "-v")
- raise stderr unless status.success?
- @runtime = "node"
+ Jekyll.logger.info "Node:", "[runtime] #{@runtime}"
end
def run(*args)
From 9176b81d3192e31e204d9a85ce29132165072c80 Mon Sep 17 00:00:00 2001
From: neveler <55753029+neveler@users.noreply.github.com>
Date: Fri, 5 Jun 2026 10:12:20 +0800
Subject: [PATCH 4/7] update
---
_plugins/node.rb | 1 -
1 file changed, 1 deletion(-)
diff --git a/_plugins/node.rb b/_plugins/node.rb
index 0eab2f15..97d4cb3c 100644
--- a/_plugins/node.rb
+++ b/_plugins/node.rb
@@ -11,7 +11,6 @@ def initialize
raise stderr unless status.success?
@runtime = "node"
end
- Jekyll.logger.info "Node:", "[runtime] #{@runtime}"
end
def run(*args)
From 14c63516bd88b45c50ed1c5f4dc3dbd8b1d32eab Mon Sep 17 00:00:00 2001
From: neveler <55753029+neveler@users.noreply.github.com>
Date: Sat, 6 Jun 2026 21:58:55 +0800
Subject: [PATCH 5/7] update
---
Gemfile | 1 -
_config.yml | 4 +-
_plugins/kramdown_enhancer.rb | 13 +---
_plugins/kramdown_enhancer/webp.js | 22 -------
_plugins/node.rb | 54 +++++++++--------
_plugins/post_process.rb | 96 +++++++++++++++---------------
_plugins/scripts/call.js | 12 ++++
_plugins/scripts/terser.js | 11 ++++
_plugins/scripts/webp.js | 17 ++++++
package.json | 19 +++---
tsconfig.node.json | 6 ++
11 files changed, 138 insertions(+), 117 deletions(-)
delete mode 100644 _plugins/kramdown_enhancer/webp.js
create mode 100644 _plugins/scripts/call.js
create mode 100644 _plugins/scripts/terser.js
create mode 100644 _plugins/scripts/webp.js
create mode 100644 tsconfig.node.json
diff --git a/Gemfile b/Gemfile
index a9a57635..dcdd1823 100644
--- a/Gemfile
+++ b/Gemfile
@@ -32,5 +32,4 @@ gem "wdm", "0.2.0", :platforms => [:windows]
gem "http_parser.rb", "0.8.0", :platforms => [:jruby]
# plugin dependencies
-gem "terser", "1.2.7"
gem "open3", "0.2.1"
diff --git a/_config.yml b/_config.yml
index cc7a6d49..bf4712e4 100644
--- a/_config.yml
+++ b/_config.yml
@@ -50,6 +50,7 @@ include:
exclude:
- README.md
- LICENSE
+ - tsconfig.node.json
- package.json
- package-lock.json
- yarn.lock
@@ -347,8 +348,9 @@ post_process:
- /assets/js/_main.js
remove_dirs:
- /assets/images/
- - /assets/js/plugins/
+ - /assets/js/lunr/
- /assets/js/vendor/
+ - /assets/js/plugins/
remove_files:
- /assets/js/meta.js
- /assets/js/_main.js
diff --git a/_plugins/kramdown_enhancer.rb b/_plugins/kramdown_enhancer.rb
index 02406a7b..bd6a0aa5 100644
--- a/_plugins/kramdown_enhancer.rb
+++ b/_plugins/kramdown_enhancer.rb
@@ -32,16 +32,6 @@ def baseurl=(input)
end
end
- class WebP
- class << self
- def encode(source, destination)
- stdout, stderr, status = Node::run("_plugins/kramdown_enhancer/webp.js", source, destination)
- raise stderr unless status.success?
- Jekyll.logger.info "KramdownEnhancer:", "[webp] Generated #{stdout}"
- end
- end
- end
-
class WebpFile < Jekyll::StaticFile
def write(dest)
true
@@ -189,7 +179,8 @@ def relative_url(input)
KramdownEnhancer.webp[file.url] = url
elsif %w[.png .jpg .jpeg .tif .tiff].include?(file.extname.downcase)
FileUtils.mkdir_p(File.dirname(destination))
- KramdownEnhancer::WebP.encode(file.path, destination)
+ result = Node.call("webp", source: file.path, destination: destination)
+ Jekyll.logger.info "Kramdown Enhancer:", "[webp] Generated #{result}"
webp_list.push(KramdownEnhancer::WebpFile.new(site, site.dest, File.dirname(url), File.basename(url)))
KramdownEnhancer.webp[file.url] = url
end
diff --git a/_plugins/kramdown_enhancer/webp.js b/_plugins/kramdown_enhancer/webp.js
deleted file mode 100644
index 1a5d1d7f..00000000
--- a/_plugins/kramdown_enhancer/webp.js
+++ /dev/null
@@ -1,22 +0,0 @@
-import fs from "fs";
-import path from "path";
-import sharp from "sharp";
-
-const [source, destination] = process.argv.slice(2);
-
-if (source === undefined || destination === undefined) {
- throw new Error("param error");
-}
-
-if (!fs.existsSync(source)) {
- throw new Error("source not exist");
-}
-
-const pwd = process.cwd();
-
-sharp(source).toFile(destination, (err) => {
- if (err) {
- throw err;
- }
- console.log(path.relative(pwd, destination));
-});
diff --git a/_plugins/node.rb b/_plugins/node.rb
index 97d4cb3c..21d0c542 100644
--- a/_plugins/node.rb
+++ b/_plugins/node.rb
@@ -1,24 +1,30 @@
-require "open3"
-
-module Node
- class << self
- def initialize
- _, _, status = Open3.capture3("bun", "-v")
- if status.success?
- @runtime = "bun"
- else
- _, stderr, status = Open3.capture3("node", "-v")
- raise stderr unless status.success?
- @runtime = "node"
- end
- end
-
- def run(*args)
- if @runtime == "bun"
- Open3.capture3("bun", "run", *args)
- else
- Open3.capture3("node", *args)
- end
- end
- end
-end
+require "json"
+require "open3"
+
+module Node
+ class << self
+ attr_reader :runtime, :package_manager
+
+ def init
+ _, _, status = Open3.capture3("bun", "-v")
+ if status.success?
+ @runtime = "bun"
+ @package_manager = "bun"
+ return
+ end
+
+ _, stderr, status = Open3.capture3("node", "-v")
+ raise stderr unless status.success?
+
+ @runtime = "node"
+ @package_manager = "npm"
+ end
+
+ def call(name, param)
+ init unless @runtime
+ stdout, stderr, status = Open3.capture3(@runtime, "_plugins/scripts/call.js", stdin_data: {"name": name, "param": param}.to_json)
+ raise stderr unless status.success?
+ JSON.parse(stdout)
+ end
+ end
+end
diff --git a/_plugins/post_process.rb b/_plugins/post_process.rb
index 62fb6ec5..d51990ff 100644
--- a/_plugins/post_process.rb
+++ b/_plugins/post_process.rb
@@ -1,49 +1,47 @@
-require "terser"
-
-Jekyll::Hooks.register :site, :post_write do |site|
- config = site.config["post_process"]
- next unless config
-
- terser = config["terser"]
- if terser.is_a?(Hash)
- terser.each do |terser_output, terser_inputs|
- next unless terser_output.is_a?(String) && terser_inputs.is_a?(Array)
-
- terser_codes = []
- terser_inputs_all_exist = true
- terser_inputs.each do |file|
- destination = File.join(site.dest, file)
- if File.exist?(destination)
- terser_codes << File.read(destination, encoding: "UTF-8")
- else
- terser_inputs_all_exist = false
- break
- end
- end
-
- if terser_inputs_all_exist
- destination = File.join(site.dest, terser_output.to_s)
- File.write(destination, Terser.compile(terser_codes.join(";")))
- Jekyll.logger.info "Post Process:", "[terser] #{terser_output}"
- end
- end
- end
-
- remove_files = config["remove_files"]
- if remove_files.is_a?(Array)
- remove_files.each do |file|
- destination = File.join(site.dest, file)
- File.delete(destination) if File.exist?(destination)
- Jekyll.logger.info "Post Process:", "[remove_files] #{file}"
- end
- end
-
- remove_dirs = config["remove_dirs"]
- if remove_dirs.is_a?(Array)
- remove_dirs.each do |dir|
- destination = File.join(site.dest, dir)
- FileUtils.rm_rf(destination) if File.directory?(destination)
- Jekyll.logger.info "Post Process:", "[remove_dirs] #{dir}"
- end
- end
-end
+Jekyll::Hooks.register :site, :post_write do |site|
+ config = site.config["post_process"]
+ next unless config
+
+ terser = config["terser"]
+ if terser.is_a?(Hash)
+ terser.each do |terser_output, terser_inputs|
+ next unless terser_output.is_a?(String) && terser_inputs.is_a?(Array)
+
+ terser_codes = []
+ terser_inputs_all_exist = true
+ terser_inputs.each do |file|
+ destination = File.join(site.dest, file)
+ if File.exist?(destination)
+ terser_codes << File.read(destination, encoding: "UTF-8")
+ else
+ terser_inputs_all_exist = false
+ break
+ end
+ end
+
+ if terser_inputs_all_exist
+ destination = File.join(site.dest, terser_output.to_s)
+ File.write(destination, Node.call("terser", code: terser_codes.join(";")))
+ Jekyll.logger.info "Post Process:", "[terser] #{terser_output}"
+ end
+ end
+ end
+
+ remove_files = config["remove_files"]
+ if remove_files.is_a?(Array)
+ remove_files.each do |file|
+ destination = File.join(site.dest, file)
+ File.delete(destination) if File.exist?(destination)
+ Jekyll.logger.info "Post Process:", "[remove_files] #{file}"
+ end
+ end
+
+ remove_dirs = config["remove_dirs"]
+ if remove_dirs.is_a?(Array)
+ remove_dirs.each do |dir|
+ destination = File.join(site.dest, dir)
+ FileUtils.rm_rf(destination) if File.directory?(destination)
+ Jekyll.logger.info "Post Process:", "[remove_dirs] #{dir}"
+ end
+ end
+end
diff --git a/_plugins/scripts/call.js b/_plugins/scripts/call.js
new file mode 100644
index 00000000..17f44193
--- /dev/null
+++ b/_plugins/scripts/call.js
@@ -0,0 +1,12 @@
+let input = "";
+
+process.stdin.on("data", (chunk) => {
+ input += chunk;
+});
+
+process.stdin.on("end", async () => {
+ const data = JSON.parse(input);
+ const mod = await import("./" + data.name + ".js");
+ const result = await mod.default(data.param);
+ console.log(JSON.stringify(result));
+});
diff --git a/_plugins/scripts/terser.js b/_plugins/scripts/terser.js
new file mode 100644
index 00000000..bc86c2b9
--- /dev/null
+++ b/_plugins/scripts/terser.js
@@ -0,0 +1,11 @@
+import fs from "fs";
+import path from "path";
+import { minify } from "terser";
+
+export default async function ({ code }) {
+ const result = await minify(code, {
+ compress: false,
+ mangle: true
+ });
+ return result.code;
+}
diff --git a/_plugins/scripts/webp.js b/_plugins/scripts/webp.js
new file mode 100644
index 00000000..3ff800df
--- /dev/null
+++ b/_plugins/scripts/webp.js
@@ -0,0 +1,17 @@
+///
+///
+
+import fs from "fs";
+import path from "path";
+import sharp from "sharp";
+
+async function webp({ source, destination }) {
+ if (Bun && Bun.Image) {
+ await Bun.file(source).image().webp().write(destination);
+ } else {
+ await sharp(source).toFile(destination);
+ }
+ return path.relative("./", destination);
+}
+
+export default webp;
diff --git a/package.json b/package.json
index 46a8140d..bd4c38b7 100644
--- a/package.json
+++ b/package.json
@@ -1,10 +1,11 @@
-{
- "type": "module",
- "dependencies": {
- "sharp": "0.34.5"
- },
- "devDependencies": {
- "@types/node": "25.9.1",
- "typescript": "6.0.3"
- }
+{
+ "devDependencies": {
+ "@types/bun": "1.3.14",
+ "@types/jquery": "3.5.34",
+ "@types/node": "25.9.1",
+ "sharp": "0.34.5",
+ "terser": "^5.48.0",
+ "typescript": "6.0.3"
+ },
+ "type": "module"
}
\ No newline at end of file
diff --git a/tsconfig.node.json b/tsconfig.node.json
new file mode 100644
index 00000000..4596c4db
--- /dev/null
+++ b/tsconfig.node.json
@@ -0,0 +1,6 @@
+{
+ "compilerOptions": {
+ "types": ["node", "bun"]
+ },
+ "include": ["_plugins/scripts/**/*"]
+}
From b5786655c84bbb2c8bf5dd9b648b1bfa8f019730 Mon Sep 17 00:00:00 2001
From: neveler <55753029+neveler@users.noreply.github.com>
Date: Sat, 6 Jun 2026 22:29:22 +0800
Subject: [PATCH 6/7] update
---
_plugins/node.rb | 20 +++++++++++---------
_plugins/scripts/webp.js | 5 +----
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/_plugins/node.rb b/_plugins/node.rb
index 21d0c542..4af04101 100644
--- a/_plugins/node.rb
+++ b/_plugins/node.rb
@@ -3,21 +3,23 @@
module Node
class << self
- attr_reader :runtime, :package_manager
+ attr_reader :runtime
def init
- _, _, status = Open3.capture3("bun", "-v")
- if status.success?
- @runtime = "bun"
- @package_manager = "bun"
- return
+ begin
+ stdout, _, status = Open3.capture3("bun", "-v")
+ if status.success?
+ @runtime = "bun"
+ Jekyll.logger.info "Node:", "[init] #{@runtime} #{stdout}"
+ return
+ end
+ rescue
end
- _, stderr, status = Open3.capture3("node", "-v")
+ stdout, stderr, status = Open3.capture3("node", "-v")
raise stderr unless status.success?
-
@runtime = "node"
- @package_manager = "npm"
+ Jekyll.logger.info "Node:", "[init] #{@runtime} #{stdout}"
end
def call(name, param)
diff --git a/_plugins/scripts/webp.js b/_plugins/scripts/webp.js
index 3ff800df..e5e8e2b0 100644
--- a/_plugins/scripts/webp.js
+++ b/_plugins/scripts/webp.js
@@ -1,12 +1,9 @@
-///
-///
-
import fs from "fs";
import path from "path";
import sharp from "sharp";
async function webp({ source, destination }) {
- if (Bun && Bun.Image) {
+ if (global.Bun && Bun.Image) {
await Bun.file(source).image().webp().write(destination);
} else {
await sharp(source).toFile(destination);
From 97b9ff7d50c45309cfaa319848c485545c142694 Mon Sep 17 00:00:00 2001
From: neveler <55753029+neveler@users.noreply.github.com>
Date: Sat, 6 Jun 2026 22:40:51 +0800
Subject: [PATCH 7/7] update
---
_plugins/scripts/webp.js | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/_plugins/scripts/webp.js b/_plugins/scripts/webp.js
index e5e8e2b0..99995364 100644
--- a/_plugins/scripts/webp.js
+++ b/_plugins/scripts/webp.js
@@ -2,7 +2,7 @@ import fs from "fs";
import path from "path";
import sharp from "sharp";
-async function webp({ source, destination }) {
+export default async function ({ source, destination }) {
if (global.Bun && Bun.Image) {
await Bun.file(source).image().webp().write(destination);
} else {
@@ -10,5 +10,3 @@ async function webp({ source, destination }) {
}
return path.relative("./", destination);
}
-
-export default webp;