1.在themes/yilia/layout/_partial/article.ejs中标注的位置添加代码
<div class="article-entry" itemprop="articleBody">
<% if (post.excerpt && index){ %>
<%- post.excerpt %>
<% if (theme.excerpt_link) { %>
<a class="article-more-a" href="<%- url_for(post.path) %>#more"><%= theme.excerpt_link %> >></a>
<% } %>
<% } else { %>
<%- post.content %>
<% } %>
<-- 在此处添加代码-->
<% if ((theme.reward_type === 2 || (theme.reward_type === 1 && post.reward)) && !index){ %>
<div class="page-reward">
<a href="javascript:;" class="page-reward-btn tooltip-top">
<div class="tooltip tooltip-east">
添加的代码如下
<%
var sUrl = url.replace(/index\.html$/, '');
sUrl = /^(http:|https:)\/\//.test(sUrl) ? sUrl : 'https:' + sUrl;
%>
<% if ((theme.declare_type === 2 || (theme.declare_type === 1 && post.declare)) && !index){ %>
<div class="declare">
<strong>本文作者:</strong>
<% if(config.author != undefined){ %>
<%= config.author%>
<% }else{%>
<font color="red">请在博客根目录“_config.yml”中填入正确的“author”</font>
<%}%>
<br>
<strong>本文链接:</strong>
<%= sUrl%>
<br>
<strong>版权声明:</strong>
本作品采用
<a rel="license" href="<%= theme.licensee_url%>"><%= theme.licensee_name%></a>
进行许可。转载请注明出处!
<% if(theme.licensee_img != undefined){ %>
<br>
<a rel="license" href="<%= theme.licensee_url%>"><img alt="知识共享许可协议" style="border-width:0" src="<%= theme.licensee_img%>"/></a>
<% } %>
</div>
<% } else {%>
<div class="declare" hidden="hidden"></div>
<% } %>
2.更改声明样式
创建新文件themes/yilia/source-src/css/declare.scss,添加如下CSS代码。
.declare {
background-color: #eaeaea;
margin-top: 2em;
border-left: 3px solid #ff1700;
padding: .5em 1em;
}
3.为themes/yilia/source-src/css/main.scss添加如下代码。
@import "./declare";
4.生成新的代码,完成修改
如果你之前没有修改过Yilia,请先使用以下命令安装依赖。
进入主题根目录cd themes/yilia,
安装依赖。
npm install
安装的时候遇到Bug
网上说用:(但是我的不行)
npm install --save-dev node-sass
最后没能解决,只好重新再搭一次(唉。。。。)
生成新主题
在themes/yilia/目录下输入:
npm run dev 生成新代码。
npm run dist 生成新代码,并压缩。
添加配置文件
修改themes/yilia/_config.yml
在需要进行版权声明的文章的md文件头部,设置属性
declare: true。