🔥 Update the multi cnd vendor service.

This commit is contained in:
elkan1788 2024-07-21 19:52:40 +08:00
parent d560e45ca2
commit 9e42b3fad1
16 changed files with 47 additions and 53 deletions

View File

@ -241,24 +241,25 @@ NexT.utils = {
}, },
getCDNResource: function (res) { getCDNResource: function (res) {
let { plugins, router } = NexT.CONFIG.vendor;
let router = NexT.CONFIG.vendor.router;
let { name, version, file, alias, alias_name } = res; let { name, version, file, alias, alias_name } = res;
let npm_name = name;
if (alias_name) npm_name = alias_name;
let res_src = ''; let res_src = '';
switch (router.type) { switch (router.type) {
case 'modern': case "modern":
let cdnjs_name = alias || name; if (alias_name) name = alias_name;
let cdnjs_file = file.replace(/^(dist|lib|source|\/js|)\/(browser\/|)/, ''); let alias_file = file.replace(/^(dist|lib|source|\/js|)\/(browser\/|)/, '');
if (cdnjs_file.indexOf('min') == -1) { if (alias_file.indexOf('min') == -1) {
cdnjs_file = cdnjs_file.replace(/\.js$/, '.min.js'); alias_file = alias_file.replace(/\.js$/, '.min.js');
} }
res_src = `${router.url}/${cdnjs_name}/${version}/${cdnjs_file}` res_src = `${router.url}/${name}/${version}/${alias_file}`;
break; break;
default: default:
res_src = `${router.url}/${npm_name}@${version}/${file}` if (alias) name = alias;
res_src = `${router.url}/${name}@${version}/${file}`;
break;
} }
return res_src; return res_src;

View File

@ -63,10 +63,10 @@ js:
# CSS 资源 # CSS 资源
# CSS Resources # CSS Resources
css: css:
- name: '@fortawesome/fontawesome-free' - name: font-awesome
version: 6.6.0 version: 6.6.0
file: css/all.min.css file: css/all.min.css
alias: font-awesome alias: '@fortawesome/fontawesome-free'
- name: animate.css - name: animate.css
version: 4.1.1 version: 4.1.1
@ -97,16 +97,16 @@ addthis:
# Comment component # Comment component
waline: waline:
js: js:
name: '@waline/client' name: waline
version: 2.15.8 version: 2.15.8
file: dist/waline.js file: dist/waline.js
alias: waline alias: "@waline/client"
css: css:
name: '@waline/client' name: waline
version: 2.15.8 version: 2.15.8
file: dist/waline.css file: dist/waline.css
alias: waline alias: "@waline/client"
artalk: artalk:
js: js:
@ -133,7 +133,7 @@ livere:
algolia: algolia:
name: algoliasearch name: algoliasearch
version: 4.24.0 version: 4.24.0
file: dist/algoliasearch.umd.min.js file: dist/algoliasearch-lite.umd.js
instant: instant:
name: instantsearch.js name: instantsearch.js
@ -146,22 +146,25 @@ plugins:
js: js:
name: mathjax name: mathjax
version: 3.2.2 version: 3.2.2
file: es5/tex-mml-chtml.min.js file: es5/tex-mml-chtml.js
katex: katex:
js: js:
- name: katex - name: katex
version: 0.16.11 alias_name: KaTeX
version: 0.16.9
file: dist/katex.min.js file: dist/katex.min.js
- name: auto-render - name: auto-render
alias_name: katex alias: katex
version: 0.16.11 alias_name: KaTeX
version: 0.16.9
file: dist/contrib/auto-render.min.js file: dist/contrib/auto-render.min.js
css: css:
name: katex name: katex
version: 0.16.11 alias_name: KaTeX
version: 0.16.9
file: dist/katex.min.css file: dist/katex.min.css
# 画图渲染 # 画图渲染
@ -174,13 +177,13 @@ plugins:
waline: waline:
js: js:
- name: pageview - name: pageview
alias_name: '@waline/client' alias_name: waline
version: 2.15.8 version: 2.15.8
file: dist/pageview.js file: dist/pageview.js
alias: waline alias: "@waline/client"
- name: comment - name: comment
alias_name: '@waline/client' alias_name: waline
version: 2.15.8 version: 2.15.8
file: dist/comment.js file: dist/comment.js
alias: waline alias: "@waline/client"

View File

@ -388,7 +388,7 @@ params:
footer: footer:
# 启动谷歌翻译功能 # 启动谷歌翻译功能
# Enable google translate in footer # Enable google translate in footer
translate: true translate: false
# 站点开始年份,默认为当下时间的年份 # 站点开始年份,默认为当下时间的年份
# Specify the year when the site was setup. # Specify the year when the site was setup.
# If not defined, current year will be used. # If not defined, current year will be used.
@ -1103,29 +1103,18 @@ params:
# --------------------------------------------------------------- # ---------------------------------------------------------------
# CDN 服务(暂时只支持 unpkg 和 cndjs # CDN 服务
# CDN Settings # CDN Settings
# --------------------------------------------------------------- # ---------------------------------------------------------------
vendors: vendors:
# The CDN provider of NexT internal scripts. # The CDN provider of NexT internal scripts.
# Available values: local | unpkg | cdnjs | qiniu | bootcdn | custom # Available values: local | cdn
# Warning: If you are using the latest master branch of NexT, please set `internal: local`
internal: local internal: local
# The default CDN provider of third-party plugins. # The default CDN provider of third-party plugins.
# Available values: local | | cdnjs | unpkg | bootcdn | staticfile | 7ed | zstatic | zeyao | jsdelivr | custom # Available values: local | cdnjs | unpkg | jsdelivr | staticfile | bootcdn | 7ed | zstatic | zeyao | custom
plugins: jsdelivr plugins: local
# TODO
# Custom CDN URL # Custom CDN URL
# For example: # For example:
# custom_cdn_url: https://cdn.jsdelivr.net/npm/${npm_name}@${version}/${minified} # custom_cdn_url: https://cdn.jsdelivr.net/npm/${npm_name}@${version}/${minified}
# custom_cdn_url: https://cdnjs.cloudflare.com/ajax/libs/${cdnjs_name}/${version}/${cdnjs_file} # custom_cdn_url: https://cdnjs.cloudflare.com/ajax/libs/${cdnjs_name}/${version}/${cdnjs_file}
#custom_cdn_url:
# TODO
# 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: imgs

View File

@ -3,17 +3,15 @@
{{ $fmt := "%s/%s@%s/%s" }} {{ $fmt := "%s/%s@%s/%s" }}
{{ $npm := .res.name }} {{ $npm := .res.name }}
{{ with .res.alias2 }}
{{ $npm = . }}
{{ end }}
{{ $file := .res.file }} {{ $file := .res.file }}
{{ if ne .router.type "nodejs" }} {{ if ne .router.type "nodejs" }}
{{ $file = replaceRE `(dist|lib|source\/js)\/` "" .res.file }}
{{ $fmt = "%s/%s/%s/%s" }}
{{ else }}
{{ with .res.alias }} {{ with .res.alias }}
{{ $npm = . }} {{ $npm = . }}
{{ end }} {{ end }}
{{ $file = replaceRE `(dist|lib|source\/js)\/` "" .res.file }}
{{ $fmt = "%s/%s/%s/%s" }}
{{ end }} {{ end }}
{{ $pluginRes := printf $fmt .router.url $npm .res.version $file }} {{ $pluginRes := printf $fmt .router.url $npm .res.version $file }}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("katex")):"function"==typeof define&&define.amd?define(["katex"],t):"object"==typeof exports?exports.renderMathInElement=t(require("katex")):e.renderMathInElement=t(e.katex)}("undefined"!=typeof self?self:this,(function(e){return function(){"use strict";var t={771:function(t){t.exports=e}},r={};function n(e){var i=r[e];if(void 0!==i)return i.exports;var a=r[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var i={};return function(){n.d(i,{default:function(){return s}});var e=n(771),t=n.n(e),r=function(e,t,r){for(var n=r,i=0,a=e.length;n<t.length;){var o=t[n];if(i<=0&&t.slice(n,n+a)===e)return n;"\\"===o?n++:"{"===o?i++:"}"===o&&i--,n++}return-1},a=/^\\begin{/,o=function(e,t){for(var n,i=[],o=new RegExp("("+t.map((function(e){return e.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")})).join("|")+")");-1!==(n=e.search(o));){n>0&&(i.push({type:"text",data:e.slice(0,n)}),e=e.slice(n));var l=t.findIndex((function(t){return e.startsWith(t.left)}));if(-1===(n=r(t[l].right,e,t[l].left.length)))break;var d=e.slice(0,n+t[l].right.length),s=a.test(d)?d:e.slice(t[l].left.length,n);i.push({type:"math",data:s,rawData:d,display:t[l].display}),e=e.slice(n+t[l].right.length)}return""!==e&&i.push({type:"text",data:e}),i},l=function(e,r){var n=o(e,r.delimiters);if(1===n.length&&"text"===n[0].type)return null;for(var i=document.createDocumentFragment(),a=0;a<n.length;a++)if("text"===n[a].type)i.appendChild(document.createTextNode(n[a].data));else{var l=document.createElement("span"),d=n[a].data;r.displayMode=n[a].display;try{r.preProcess&&(d=r.preProcess(d)),t().render(d,l,r)}catch(e){if(!(e instanceof t().ParseError))throw e;r.errorCallback("KaTeX auto-render: Failed to parse `"+n[a].data+"` with ",e),i.appendChild(document.createTextNode(n[a].rawData));continue}i.appendChild(l)}return i},d=function e(t,r){for(var n=0;n<t.childNodes.length;n++){var i=t.childNodes[n];if(3===i.nodeType){for(var a=i.textContent,o=i.nextSibling,d=0;o&&o.nodeType===Node.TEXT_NODE;)a+=o.textContent,o=o.nextSibling,d++;var s=l(a,r);if(s){for(var f=0;f<d;f++)i.nextSibling.remove();n+=s.childNodes.length-1,t.replaceChild(s,i)}else n+=d}else 1===i.nodeType&&function(){var t=" "+i.className+" ";-1===r.ignoredTags.indexOf(i.nodeName.toLowerCase())&&r.ignoredClasses.every((function(e){return-1===t.indexOf(" "+e+" ")}))&&e(i,r)}()}},s=function(e,t){if(!e)throw new Error("No element provided to render");var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);r.delimiters=r.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}],r.ignoredTags=r.ignoredTags||["script","noscript","style","textarea","pre","code","option"],r.ignoredClasses=r.ignoredClasses||[],r.errorCallback=r.errorCallback||console.error,r.macros=r.macros||{},d(e,r)}}(),i=i.default}()}));