diff --git a/README.md b/README.md index 438abfe..53976f0 100644 --- a/README.md +++ b/README.md @@ -40,4 +40,5 @@ valine: visitor: false # leancloud-counter-security is not supported for now. When visitor is set to be true, appid and appkey are recommended to be the same as leancloud_visitors' for counter compatibility. Article reading statistic https://valine.js.org/visitor.html comment_count: true # If false, comment count will only be displayed in post page, not in home page recordIP: false # Whether to record the commenter IP + libUrl: https://cdnjs.cloudflare.com/ajax/libs/valine/1.5.1/Valine.min.js # Valine.min.js file URL in CDN (or local path) ``` diff --git a/default.yaml b/default.yaml index 9373b06..c2345fb 100644 --- a/default.yaml +++ b/default.yaml @@ -16,3 +16,4 @@ valine: recordIP: false # Whether to record the commenter IP enableQQ: false # Whether to enable the Nickname box to automatically get QQ Nickname and QQ Avatar requiredFields: [] # Set required fields: [nick] | [nick, mail] + libUrl: https://cdnjs.cloudflare.com/ajax/libs/valine/1.5.1/Valine.min.js # Valine.min.js file URL in CDN (or local path) diff --git a/valine.njk b/valine.njk index 2793241..93c86c3 100644 --- a/valine.njk +++ b/valine.njk @@ -1,6 +1,7 @@ {%- if next_data %} {{ next_data('valine', config.valine, { + libUrl: config.valine.libUrl | default('https://cdnjs.cloudflare.com/ajax/libs/valine/1.5.1/Valine.min.js',true), el: '#valine-comments', path: url_for(page.path) | replace(r/index\.html$/, ''), serverURLs: config.valine.serverURLs or 'https://' + config.valine.appId.slice(0, 8) | lower + '.api.lncldglobal.com' @@ -9,7 +10,7 @@ document.addEventListener('page:loaded', () => { NexT.utils.loadComments(CONFIG.valine.el) .then(() => NexT.utils.getScript( - 'https://fastly.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js', + CONFIG.valine.libUrl, { condition: window.Valine } )) .then(() => { @@ -21,9 +22,10 @@ document.addEventListener('page:loaded', () => { {%- else %} {%- set serverURLs = config.valine.serverURLs or 'https://' + config.valine.appId.slice(0, 8) | lower + '.api.lncldglobal.com' %} +{%- set libUrl = config.valine.libUrl | default('https://cdnjs.cloudflare.com/ajax/libs/valine/1.5.1/Valine.min.js',true) %}