美文网首页
一招解决给hexo博客添加版权声明的方法

一招解决给hexo博客添加版权声明的方法

作者: KangSmit的算法那些事儿 | 来源:发表于2020-04-07 18:51 被阅读0次

今天更换了新的Hexo主题:
hexo-theme-hiero

预览我的博客
觉得挺好看的,文章底部没有版权说明,自己动手也加上了。

新建文件 copyright.ejs

themes\hiker\layout\_partial新建文件copyright.ejs

打开copyright.ejs,添加一下内容。

<div>
        <ul class="post-copyright">
          <li class="post-copyright-author">
          <strong><%= __('copyright.author') %> </strong><%= config.author%></a>
          </li>
          <li class="post-copyright-link">
          <strong><%= __('copyright.link') %> </strong>
          <a href="<%- config.root %><%- post.path %>" target="_blank" title="<%= post.title %>"><%- config.url %>/<%- post.path %></a>
          </li>
          <li class="post-copyright-license">
            <strong><%= __('copyright.license_title') %>  </strong>
            <%= __('copyright.left_license_content') %><a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">CC BY-NC-ND 4.0</a>
            <%= __('copyright.right_license_content') %>
          </li>
        </ul>
      <div>
复制代码

修改article.ejs文件

打开themes\hiker\layout\_partial\article.ejs添加一下内容,位置介于donate和comment之间

<% if (!index && theme.donate.enable){ %>
        <%- partial('donate') %>
      <% } %>
       <!-- 要添加的内容 -->
      <% if (!index && theme.copyright.enable){ %>
      <%- partial('copyright') %>
      <% } %>
      <!---->
      <% if (!index && post.comments && (theme.gentie_productKey || theme.duoshuo_shortname || theme.disqus_shortname || theme.uyan_uid || theme.wumii || theme.livere_shortname)){ %>
        <%- partial('comment') %>
      <% } %>
复制代码

我的截图如下:介于donate和comment之间

image.png

修改 article.styl

修改themes\hiker\source\css\_partial\article.styl,在末端添加以下内容。

.post-copyright {
    margin: 2em 0 0;
    padding: 0.5em 1em;
    border-left: 3px solid #FF1700;
    background-color: #F9F9F9;
    list-style: none;
}

.post-copyright li {
    line-height: 30px;
}
复制代码

修改语言文件

在themes\hiker\languages中,找到你应用的语言文件,例如zh-TW,打开并添加以下内容。

copyright:
    author: "作者: "
    link: "文章连结: "
    license_title: "版权声明: "
    left_license_content: "本网志所有文章除特别声明外,均采用 "
    right_license_content: "许可协议。转载请注明出处!"
复制代码

修改主题设置文件

打开themes\hiker\_config.yml,添加以下内容。

#版权信息
copyright:
    enable: true
复制代码

引用文献链接:https://juejin.im/post/5d728f506fb9a06aef090e47

相关文章

网友评论

      本文标题:一招解决给hexo博客添加版权声明的方法

      本文链接:https://www.haomeiwen.com/subject/obxophtx.html