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

Use new api for Artalk v2.5.0+ update #7

Merged
merged 1 commit into from
Mar 16, 2023
Merged
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
7 changes: 3 additions & 4 deletions artalk.njk
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{{ next_data('artalk', config.artalk, {
el: '#comments',
pageKey: url_for(page.path) | replace(r/index\.html$/, ''),
pageTitle: page.title,
locale: page.lang | default('zh-CN', true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

语言可以在侧边栏控制中心修改

pageTitle: page.title
}) }}

<link rel="stylesheet" href="{{ config.artalk.cssUrl }}">
Expand All @@ -17,15 +16,15 @@
condition: window.Artalk
}))
.then(() => {
new Artalk(CONFIG.artalk);
Artalk.init(CONFIG.artalk);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new Artalk 创建新实例对象替换为新版提供的函数,防止反复创建实例浪费资源

});

} else {

NexT.utils.getScript(CONFIG.artalk.jsUrl, {
condition: window.Artalk
}).then(() => {
Artalk.LoadCountWidget({
Artalk.loadCountWidget({
server: CONFIG.artalk.server,
site: CONFIG.artalk.site,
pvEl: '#ArtalkPV',
Expand Down
6 changes: 3 additions & 3 deletions default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ artalk:

# Frontend resources CDN, you can set this to your preferred CDN
## Reference: https://artalk.js.org/guide/frontend/install.html
jsUrl: https://unpkg.com/artalk@2/dist/Artalk.js
cssUrl: https://unpkg.com/artalk@2/dist/Artalk.css
jsUrl: https://artalk.example.com/dist/Artalk.js
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后端程序中包含了对应版本的前端资源文件,可保证版本一致性,但同时也推荐使用 CDN 资源加快速度。

cssUrl: https://artalk.example.com/dist/Artalk.css

# Page views count
pvCount: true
Expand All @@ -27,4 +27,4 @@ artalk:

# Use backend to config
## Reference: https://artalk.js.org/guide/backend/fe-control.html
useBackendConf: false
useBackendConf: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新版 useBackendConf 已修改为默认开启