Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CDN settings #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
1 change: 1 addition & 0 deletions default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 4 additions & 2 deletions valine.njk
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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(() => {
Expand All @@ -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) %}
<script>
NexT.utils.loadComments('#valine-comments', () => {
NexT.utils.getScript('https://fastly.jsdelivr.net/npm/[email protected]/dist/Valine.min.js', () => {
NexT.utils.getScript({{libUrl}}, () => {
new Valine(Object.assign({{ config.valine | safedump }}, {
el: '#valine-comments',
path: {{ url_for(page.path) | replace(r/index\.html$/, '') | safedump }},
Expand Down