blinkfox / hexo-theme-matery

A beautiful hexo blog theme with material design and responsive design.一个基于材料设计和响应式设计而成的全面、美观的Hexo主题。国内访问:http://blinkfox.com
https://blinkfox.github.io/
Apache License 2.0
5.24k stars 1.25k forks source link

请问可以支持Twikoo吗?谢谢 #892

Closed byncn closed 1 year ago

byncn commented 1 year ago

请问可以支持Twikoo吗?https://twikoo.js.org/ 我不管怎么修改添加都改不出来。谢谢了

kezade commented 1 year ago

请问可以支持Twikoo吗?https://twikoo.js.org/ 我不管怎么修改添加都改不出来。谢谢了

twikoo需要后端,你可以去zeabur、railway等这些地方部署,应用市场应该有。可以去试试

byncn commented 1 year ago

请问可以支持Twikoo吗?https://twikoo.js.org/ 我不管怎么修改添加都改不出来。谢谢了

twikoo需要后端,你可以去zeabur、railway等这些地方部署,应用市场应该有。可以去试试

我已经配置成功了。给后来人一个参考。 一. 主题config.yml添加以下代码

twikoo:
  enable: true
  envId: https://xxx.vercel.app # 环境 ID

libs:
  css:
      twikoo: /libs/twikoo/twikoo.all.min.js

二.在\layout_partial\post-detail.ejs中添加代码

<% if (theme.twikoo && theme.twikoo.enable) { %>
    <%- partial('_partial/twikoo') %>
<% } %>

三.新建\layout_partial\twikoo.ejs文件并添加代码

<div class="card twikoo-card" data-aos="fade-up">
    <div class="comment_headling" style="font-size: 20px; font-weight: 700; position: relative; padding-left: 20px; top: 15px; padding-bottom: 5px;">
        <i class="fas fa-comments fa-fw" aria-hidden="true"></i>
        <span>评论</span>
    </div>
    <div class="card-content" style="display: grid">
        <div id="tcomments"></div>
    </div>
</div>
<script src="<%- theme.jsDelivr.url %><%- url_for(theme.libs.js.twikoo) %>"></script>
<script>
    twikoo.init({
        envId: '<%- theme.twikoo.envId %>',
        el: '#tcomments',
        region: '<%- theme.twikoo.region %>',
        path: '<%- theme.twikoo.path %>'
    }).then(function () {
        var tkInputs = document.querySelector('#twikoo').getElementsByTagName('input');
        for (var tkInputsIndex = 0; tkInputsIndex < tkInputs.length; tkInputsIndex++) {
            if (tkInputs[tkInputsIndex]) {
                tkInputs[tkInputsIndex].classList.add('browser-default');
            }
        }
    });
</script>

四.在\layout\contact.ejs中添加代码

<% if (theme.twikoo && theme.twikoo.enable) { %>
<%- partial('_partial/twikoo') %>
<% } %>

五.在\layout\friends.ejs中添加代码

<% if (theme.twikoo && theme.twikoo.enable) { %>
<%- partial('_partial/twikoo') %>
<% } %>
kezade commented 1 year ago

我记得matery自带的twikoo.all.min.js有点过时了,需要更新下。

请问可以支持Twikoo吗?https://twikoo.js.org/ 我不管怎么修改添加都改不出来。谢谢了

twikoo需要后端,你可以去zeabur、railway等这些地方部署,应用市场应该有。可以去试试

我已经配置成功了。给后来人一个参考。 一. 主题config.yml添加以下代码

twikoo:
  enable: true
  envId: https://xxx.vercel.app # 环境 ID

libs:
  css:
    twikoo: /libs/twikoo/twikoo.all.min.js

二.在\layout_partial\post-detail.ejs中添加代码

<% if (theme.twikoo && theme.twikoo.enable) { %>
    <%- partial('_partial/twikoo') %>
<% } %>

三.新建\layout_partial\twikoo.ejs文件并添加代码

<div class="card twikoo-card" data-aos="fade-up">
    <div class="comment_headling" style="font-size: 20px; font-weight: 700; position: relative; padding-left: 20px; top: 15px; padding-bottom: 5px;">
        <i class="fas fa-comments fa-fw" aria-hidden="true"></i>
        <span>评论</span>
    </div>
    <div class="card-content" style="display: grid">
        <div id="tcomments"></div>
    </div>
</div>
<script src="<%- theme.jsDelivr.url %><%- url_for(theme.libs.js.twikoo) %>"></script>
<script>
    twikoo.init({
        envId: '<%- theme.twikoo.envId %>',
        el: '#tcomments',
        region: '<%- theme.twikoo.region %>',
        path: '<%- theme.twikoo.path %>'
    }).then(function () {
        var tkInputs = document.querySelector('#twikoo').getElementsByTagName('input');
        for (var tkInputsIndex = 0; tkInputsIndex < tkInputs.length; tkInputsIndex++) {
            if (tkInputs[tkInputsIndex]) {
                tkInputs[tkInputsIndex].classList.add('browser-default');
            }
        }
    });
</script>

四.在\layout\contact.ejs中添加代码

<% if (theme.twikoo && theme.twikoo.enable) { %>
<%- partial('_partial/twikoo') %>
<% } %>

五.在\layout\friends.ejs中添加代码

<% if (theme.twikoo && theme.twikoo.enable) { %>
<%- partial('_partial/twikoo') %>
<% } %>