100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > hexo+yilia添加版权声明

hexo+yilia添加版权声明

时间:2019-05-24 23:11:15

相关推荐

hexo+yilia添加版权声明

文章目录

1.借鉴修改版1.1在文末添加声明1.2添加样式1.3在主题中开启设置2.升级版-配置版

添加版权声明,效果图:

参考:

版权声明在Hexo中自动为Yilia主题增加版权声明hexo-theme-yilia-plus主题的版权声明

1.借鉴修改版

1.1在文末添加声明

themes/yilia/layout/_partial/article.ejs文件的指定位置如下:

<%- post.content %><% } %><-- 在此处添加代码--><% if ((theme.reward_type === 2 || (theme.reward_type === 1 && post.reward)) && !index){ %>

添加如下代码:

<!-- 添加版权声明 --><%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><a href="<%= config.url %>/<%= post.path %>" title="<%= post.title %>" target="_blank"><%= config.url %>/<%= post.path %></a><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><% } %><!-- 添加版权声明 -->

1.2添加样式

在文件yilia/source/main.0cf68a.css中添加:

/*版权声明的样式*/.declare {background-color: #eaeaea;margin-top: 2em;border-left: 3px solid #ff1700;padding: .5em 1em; }

1.3在主题中开启设置

在文件themes/yilia/_config.yml中添加:

# 版权声明#在需要进行版权声明的文章的md文件头部,设置属性declare: true。#版权基础设定:0-关闭声明; 1-文章对应的md文件里有declare: true属性,才有版权声明; 2-所有文章均有版权声明declare_type: 1licensee_url: /licenses/by-nc-sa/4.0/ #当前应用的版权协议地址。licensee_name: '知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议' #版权协议的名称licensee_img: /l/by-nc-sa/4.0/88x31.png #版权协议的Logo

效果图:

2.升级版-配置版

修改:H:\Hexo\themes\yilia\_config.yml:

# 版权声明#在需要进行版权声明的文章的md文件头部,设置属性declare: true。#版权基础设定:0-关闭声明; 1-文章对应的md文件里有declare: true属性,才有版权声明; 2-所有文章均有版权声明declare:declare_type: 1licensee_url: /licenses/by-nc-sa/4.0/ #当前应用的版权协议地址。licensee_name: 'CC BY-NC-SA 4.0'#版权协议的名称licensee_alias: '知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议' # alias别名licensee_img: /l/by-nc-sa/4.0/88x31.png #版权协议的Logo

新建H:\Hexo\themes\yilia\layout\_partial\post\declare.ejs

<!-- 《添加版权声明 --><!--添加版权声明/JoeyBling/hexo-theme-yilia-plus/commit/c1215e132f6d5621c5fea83d3c4f7ccbcca074a3--><%var sUrl = url.replace(/index\.html$/, '');sUrl = /^(http:|https:)\/\//.test(sUrl) ? sUrl : 'https:' + sUrl;%><!-- #版权基础设定:0-关闭声明; 1-文章对应的md文件里有declare: true属性,才有版权声明; 2-所有文章均有版权声明 --><% if ((theme.declare.declare_type === 2 || (theme.declare.declare_type === 1 && post.declare)) && !index){ %><div class="declare"><strong class="author">本文作者:</strong><% if(config.author != undefined){ %><%= config.author%><% }else{%><font color="red">请在博客根目录“_config.yml”中填入正确的“author”</font><%}%><br><strong class="create-time">发布时间:</strong><%- date(post.date, 'YYYY-MM-DD') %><br><strong class="update-time">最后更新:</strong><%- date(post.updated, 'YYYY-MM-DD') %><br><strong class="article-titles">本文标题:</strong><a href="<%= config.url %>/<%= post.path %>" title="<%= post.title %>" target="_blank"><%= post.title %></a><br><strong class="article-url">本文链接:</strong><a href="<%= config.url %>/<%= post.path %>" title="<%= post.title %>" target="_blank"><%= config.url %>/<%= post.path %></a><br><strong class="copyright">版权声明:</strong>本作品采用<a rel="license" href="<%= theme.declare.licensee_url%>" title="<%= theme.declare.licensee_alias %>"><%= theme.declare.licensee_name%></a>许可协议进行许可。转载请注明出处!<% if(theme.declare.licensee_img != undefined){ %><br><a rel="license" href="<%= theme.declare.licensee_url%>"><img alt="知识共享许可协议" style="border-width:0" src="<%= theme.declare.licensee_img%>"/></a><% } %></div><% } else {%><div class="declare" hidden="hidden"></div><% } %><!-- 添加版权声明》 -->

修改H:\Hexo\themes\yilia\layout\_partial\article.ejs

<!-- 《添加版权声明 --><% if(theme.declare){%><%- partial('post/declare') %><% } %><!-- 添加版权声明》 -->

效果图:

文章首发于:hexo+yilia添加版权声明

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。