From 8b4b4004c1cec9c8538d530ba3a55306ae42b23c Mon Sep 17 00:00:00 2001 From: Ljcbaby <46277145+ljcbaby@users.noreply.github.com> Date: Mon, 24 Jan 2022 13:14:14 +0800 Subject: [PATCH] Add back `theme.js` (#439) * fix theme.js * add preconnect support --- _config.yml | 2 ++ scripts/helpers/engine.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/_config.yml b/_config.yml index f0cfff6..be1e599 100644 --- a/_config.yml +++ b/_config.yml @@ -883,5 +883,7 @@ vendors: # Assets # Accelerate delivery of static files using a CDN +# The js option is only valid when vendors.internal is local. css: css +js: js images: images diff --git a/scripts/helpers/engine.js b/scripts/helpers/engine.js index beaf178..db3f8a6 100644 --- a/scripts/helpers/engine.js +++ b/scripts/helpers/engine.js @@ -25,7 +25,7 @@ hexo.extend.helper.register('next_js', function(file, pjax = false) { version : next_version, file : 'source/js/' + file, minified: 'source/js/' + file.replace(/\.js$/, '.min.js'), - local : this.url_for(`js/${file}`), + local : this.url_for(`${this.theme.js}/${file}`), custom : custom_cdn_url }); const src = links[internal] || links.local; @@ -55,7 +55,7 @@ hexo.extend.helper.register('next_pre', function() { const { enable, host } = this.theme.font; const { internal, plugins, custom_cdn_url } = this.theme.vendors; const links = { - local : '', + local : parse(this.theme.js || '').hostname, jsdelivr: 'https://cdn.jsdelivr.net', unpkg : 'https://unpkg.com', cdnjs : 'https://cdnjs.cloudflare.com',