perf: optimize gitalk comment plugin
This commit is contained in:
parent
136359bf00
commit
18958d0cb1
|
@ -8,13 +8,19 @@
|
|||
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
|
||||
<div id="gitalk-container"></div>
|
||||
<script>
|
||||
let __gitalk__pathname = decodeURI(location.pathname);
|
||||
const __gitalk__pathnameLength = __gitalk__pathname.length;
|
||||
const __gitalk__pathnameMaxLength = 50;
|
||||
if (__gitalk__pathnameLength > __gitalk__pathnameMaxLength) {
|
||||
__gitalk__pathname = __gitalk__pathname.substring(0, __gitalk__pathnameMaxLength - 3) + '...';
|
||||
}
|
||||
const gitalk = new Gitalk({
|
||||
clientID: '<%= theme.comment.gitalk.client_id %>',
|
||||
clientSecret: '<%= theme.comment.gitalk.client_secret %>',
|
||||
repo: '<%= theme.comment.gitalk.repository %>',
|
||||
owner: '<%= theme.comment.gitalk.github_id %>',
|
||||
admin: ['<%= theme.comment.gitalk.github_id %>'],
|
||||
id: location.pathname,
|
||||
id: __gitalk__pathname,
|
||||
language: '<%= config.language %>'
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
|
|
Loading…
Reference in New Issue