1
- <script >
2
- volantis .layoutHelper (" comments" ,` <div id="waline"><i class="fa-solid fa-cog fa-spin fa-fw fa-2x"></i></div>` )
3
-
1
+ <script type =" module" >
2
+ import { init } from ' <%- theme.cdn.waline_js %>' ;
3
+
4
+ volantis .layoutHelper (" comments" , ` <div id="waline"><i class="fa-solid fa-cog fa-spin fa-fw fa-2x"></i></div>` )
5
+
4
6
function p_waline () {
5
- if (! document .querySelector (" #waline" ))return ;
7
+ if (! document .querySelector (" #waline" )) return ;
8
+
6
9
let locale = {};
7
10
let path = pdata .commentPath ;
8
11
let pagePlaceholder = pdata .commentPlaceholder || " <%= theme.comments.waline.placeholder %>" ;
9
12
if (path .length == 0 ) {
10
13
let defaultPath = ' <%= theme.comments.waline.path %>' ;
11
14
path = defaultPath || decodeURI (window .location .pathname );
12
15
}
13
- if (pagePlaceholder .length != 0 ) {
16
+ if (pagePlaceholder .length != 0 ) {
14
17
locale .placeholder = pagePlaceholder;
15
18
}
16
19
17
20
try {
18
- Waline . init (Object .assign (Object .assign (< %- JSON .stringify (theme .comments .waline ) % > , {
21
+ init (Object .assign (Object .assign (< %- JSON .stringify (theme .comments .waline ) % > , {
19
22
el: ' #waline' ,
20
23
path: path,
21
24
// https://github.com/volantis-x/hexo-theme-volantis/issues/713
24
27
let headers = new Headers ();
25
28
headers .set (' Accept' , ' application/json' );
26
29
< % if (!! theme .comments .waline .imageUploader ? .token ) { % >
27
- headers .set (' <%= theme.comments.waline.imageUploader?.tokenName %>' , ' <%= theme.comments.waline.imageUploader?.token %>' )
30
+ headers .set (' <%= theme.comments.waline.imageUploader?.tokenName %>' , ' <%= theme.comments.waline.imageUploader?.token %>' );
28
31
< % } % >
29
32
let formData = new FormData ();
30
33
formData .append (' <%= theme.comments.waline.imageUploader?.fileName %>' , file);
31
- return fetch (' <%= theme.comments.waline.imageUploader?.api %>' ,{
34
+ return fetch (' <%= theme.comments.waline.imageUploader?.api %>' , {
32
35
method: ' POST' ,
33
36
body: formData,
34
37
headers: headers
35
- }).then ((resp ) => resp .json ())
36
- .then ((resp ) => resp.< %= theme .comments .waline .imageUploader ? .resp % > )
38
+ }).then ((resp ) => resp .json ())
39
+ .then ((resp ) => resp.< %= theme .comments .waline .imageUploader ? .resp % > );
37
40
},
38
41
< % } % >
39
42
locale,
40
- }),pdata .commentConfig ));
43
+ }), pdata .commentConfig ));
41
44
} catch (error) {
42
- alert (` Waline ${ error} ` )
45
+ alert (` Waline ${ error} ` );
43
46
}
44
- fancybox_waline ()
47
+ fancybox_waline ();
45
48
}
46
49
47
50
function fancybox_waline () {
48
- if (typeof VolantisFancyBox === " undefined" ) {
51
+ if (typeof VolantisFancyBox === " undefined" ) {
49
52
const checkFancyBox = setInterval (() => {
50
- if (typeof VolantisFancyBox === " undefined" ) return ;
53
+ if (typeof VolantisFancyBox === " undefined" ) return ;
51
54
clearInterval (checkFancyBox);
52
55
VolantisFancyBox .bind (' #waline .wl-content img:not(.wl-emoji)' );
53
- })
56
+ });
54
57
} else {
55
58
VolantisFancyBox .bind (' #waline .wl-content img:not(.wl-emoji)' );
56
59
}
57
60
}
58
61
59
- volantis .css (' <%= theme.cdn.waline_css %>' )
60
- volantis .js (' <%- theme.cdn.waline_js %>' ).then (p_waline)
61
- < / script>
62
+ volantis .css (' <%= theme.cdn.waline_css %>' );
63
+ volantis .js (' <%- theme.cdn.waline_js %>' ).then (p_waline);
64
+ < / script>
0 commit comments