hexo-theme-volantis 5.1.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.2.0](https://github.com/volantis-x/hexo-theme-volantis/compare/v5.1.1...v5.2.0) (2022-05-21)
4
+
5
+
6
+ ### Features
7
+
8
+ * **artalk:** Add support for using custom imgUploader ([b69c502](https://github.com/volantis-x/hexo-theme-volantis/commit/b69c502565d8b4d6d1ad1a58fdc3fc00ac200cef))
9
+
3
10
  ### [5.1.1](https://github.com/volantis-x/hexo-theme-volantis/compare/v5.1.0...v5.1.1) (2022-05-19)
4
11
 
5
12
 
package/_config.yml CHANGED
@@ -284,9 +284,19 @@ comments:
284
284
  server: https://yours-artalk-domain # 修改为自建的后端服务地址
285
285
  path: # 全局评论地址
286
286
  placeholder: # 评论占位
287
+ # artalk 有三类图片:1.上传至服务端 2.上传至服务端后利用upgit上传至图床 3.前端上传至图床(本配置为此类)
288
+ # 配置此项时将覆盖服务端上传能力
289
+ imgUploader:
290
+ # 以兰空图床为例,下列填写内容为:
291
+ # url: 'https://xxxxxx/api/v1/upload'
292
+ # token: 'Bearer xxxxxxxxxxxxxx'
293
+ # resp: 'data.links.url'
294
+ api: # 图床地址
295
+ token: # 图床验证
296
+ resp: # 图片地址返回值的字段
287
297
  # 更多置项可在 Artalk 后端进行配置,详见 https://artalk.js.org/guide/backend/fe-control.html
288
298
  # 也可以在此处继续参考上方例子进行配置,不建议重写配置的字段除上方所述外还有:
289
- # [el, useBackendConf, pageKey, pageTitle, site, darkMode, pvEl]
299
+ # [el, useBackendConf, pageKey, pageTitle, site, darkMode, pvEl, imgUploader]
290
300
 
291
301
  # giscus
292
302
  # https://giscus.app
@@ -13,6 +13,9 @@
13
13
  if (path.length == 0) {
14
14
  path = '<%= theme.comments.artalk.path %>' || decodeURI(window.location.pathname);
15
15
  }
16
+ if(!'<%= config.permalink %>'.includes('/index.html')) {
17
+ path = path.replaceAll('/index.html', '/')
18
+ }
16
19
 
17
20
  volantis.artalk = new Artalk(Object.assign(<%- JSON.stringify(theme.comments.artalk) %>, {
18
21
  el: '#artalk_container',
@@ -22,7 +25,25 @@
22
25
  useBackendConf: true,
23
26
  site: '<%= config.title %>',
24
27
  darkMode: volantis.dark.mode === "dark",
25
- pvEl: '#artalk_visitors'
28
+ pvEl: '#artalk_visitors',
29
+
30
+ <% if(!!theme.comments.artalk.imgUploader?.api){ %>
31
+ imgUploader: function(file) {
32
+ let headers = new Headers();
33
+ headers.set('Accept', 'application/json');
34
+ <% if(!!theme.comments.artalk.imgUploader?.token) { %>
35
+ headers.set('Authorization', '<%= theme.comments.artalk.imgUploader?.token %>')
36
+ <% } %>
37
+ let formData = new FormData();
38
+ formData.append('file', file);
39
+ return fetch('<%= theme.comments.artalk.imgUploader?.api %>',{
40
+ method: 'POST',
41
+ body: formData,
42
+ headers: headers
43
+ }).then((resp) => resp.json())
44
+ .then((resp) => resp.<%= theme.comments.artalk.imgUploader?.resp %>)
45
+ },
46
+ <% } %>
26
47
  }));
27
48
 
28
49
  volantis.artalk.then(ctx => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-volantis",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "description": "Elegant and powerful theme for Hexo.",
5
5
  "main": "package.json",
6
6
  "scripts": {