-
Notifications
You must be signed in to change notification settings - Fork 5
/
valine.njk
36 lines (32 loc) · 1.15 KB
/
valine.njk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{%- if next_data %}
{{ next_data('valine', config.valine, {
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'
}) }}
<script>
document.addEventListener('page:loaded', () => {
NexT.utils.loadComments(CONFIG.valine.el)
.then(() => NexT.utils.getScript(
'https://fastly.jsdelivr.net/npm/[email protected]/dist/Valine.min.js',
{ condition: window.Valine }
))
.then(() => {
new Valine(CONFIG.valine);
});
});
</script>
{%- else %}
{%- set serverURLs = config.valine.serverURLs or 'https://' + config.valine.appId.slice(0, 8) | lower + '.api.lncldglobal.com' %}
<script>
NexT.utils.loadComments('#valine-comments', () => {
NexT.utils.getScript('https://fastly.jsdelivr.net/npm/[email protected]/dist/Valine.min.js', () => {
new Valine(Object.assign({{ config.valine | safedump }}, {
el: '#valine-comments',
path: {{ url_for(page.path) | replace(r/index\.html$/, '') | safedump }},
serverURLs: {{ serverURLs | safedump }}
}));
}, window.Valine);
});
</script>
{%- endif %}