Skip to content

Commit

Permalink
perf(comment): optimize version matching of waline
Browse files Browse the repository at this point in the history
  • Loading branch information
XPoet committed May 15, 2024
1 parent c8140e6 commit 1c2895b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ comment:
waline:
server_url: # Server URL
reaction: false # Post reactions, Option values: true | false
version: 2 # Waline version, default use v2
version: 3 # Waline version, default use v3

# Giscus
# See: https://github.com/giscus/giscus
Expand Down
6 changes: 4 additions & 2 deletions layout/_partial/comment/plugins/waline.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ let {
options: waline_options = {}
} = theme?.comment?.waline || {}
if (!waline_version) { waline_version = '2' }
waline_version = String(waline_version).trim()
const esm_load = String(waline_version) === '3'
if (!waline_version) { waline_version = '3' }
const esm_load = waline_version === '3' || /^3\..*/.test(waline_version)
let cdn_css = `//cdn.jsdelivr.net/npm/@waline/client@v${waline_version}/dist/waline.css`
let cdn_css_meta = `//cdn.jsdelivr.net/npm/@waline/client@v${waline_version}/dist/waline-meta.css`
Expand Down

0 comments on commit 1c2895b

Please sign in to comment.