本文最后更新于 2025年3月15日 晚上
主题修改
参考:
Fluid 注入代码替换评论组件会替换整个layout/_partials/comments.ejs,直接改主题为 fluid-1.9.8-mod
控制台输入localStorage.setItem('dsqjs_mode', 'dsqjs')后回车再刷新页面可预览 DisqusJS。
修改_config.主题.yml
1 2 3 4 5 6 7 8 9 10
| disqus: shortname: disqusjs: true apikey: - 'KEY1' - 'KEY2' api: https://disqus.skk.moe/disqus/ admin: adminLabel:
|
修改layout/_partials/comments/disqus.ejs
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 37
| <% if (theme.disqus.shortname) { %> <div class="disqus" style="width:100%"> <div id="disqus_thread"></div> <% if (theme.disqus.disqusjs) { %> <script> Fluid.utils.loadComments('#disqus_thread', function() { Fluid.utils.createCssLink('<%= url_join(theme.static_prefix.disqusjs, 'disqusjs.css') %>'); Fluid.utils.createScript('<%= url_join(theme.static_prefix.disqusjs, 'disqus.js') %>', function() { new DisqusJS({ shortname: '<%= theme.disqus.shortname %>', apikey: <%- JSON.stringify(theme.disqus.apikey) %>, api: '<%= theme.disqus.api %>', url: '<%= page.permalink %>', identifier: '<%= url_for(page.path) %>', admin: '<%= theme.disqus.admin %>', adminLabel: '<%= theme.disqus.adminLabel %>' }); }); }); </script> <% } else { %> <script type="text/javascript"> var disqus_config = function() { this.page.url = '<%= page.permalink %>'; this.page.identifier = '<%= url_for(page.path) %>'; }; Fluid.utils.loadComments('#disqus_thread', function() { var d = document, s = d.createElement('script'); s.src = '//' + '<%= theme.disqus.shortname %>' + '.disqus.com/embed.js'; s.setAttribute('data-timestamp', new Date()); (d.head || d.body).appendChild(s); }); </script> <% } %> <noscript>Please enable JavaScript to view the comments</noscript> </div> <% } %>
|