給Icarus加上版權(quán)保護

本文首發(fā)于Ray's Blog
最近把博客的主題換成了Icarus。這個主題不自帶版權(quán)保護,我決定自己動手加一個。

Step 1. 打開/themes/icarus//languages/zh-CN.yml,添加如下內(nèi)容:

copyright:
    title: "本文標(biāo)題: "
    author: "本文作者: "
    link: "原文鏈接: "
    license_title: "版權(quán)聲明: "
    date: "發(fā)布時間: "
    license_content: "本網(wǎng)站所有文章除特別聲明外,均采用 %s 許可協(xié)議。非商業(yè)轉(zhuǎn)載請注明出處!"

Step 2. 打開/themes/icarus/layout,新建copyright.ejs,內(nèi)容如下:

<div>
  <ul class="post-copyright">
    <li class="post-copyright-title">
      <strong><%= __('copyright.title') %></strong>
      <a href="<%- config.root %><%- post.path %>" target="_blank" title="本文標(biāo)題: <%- page.title %>"><%- page.title %></a>
    </li>
    <li class="post-copyright-author">
      <strong><%= __('copyright.author') %> </strong></a>
      <a href="<%- config.root %>" target="_blank" title="本文作者: <%= config.author%>"><%= config.author%></a>
    </li>
    <li class="post-copyright-link">
      <strong><%= __('copyright.link') %> </strong>
      <a href="<%- config.root %><%- post.path %>" target="_blank" title="原文鏈接: <%- config.url %>/<%- post.path %>"><%- config.url %>/<%- post.path %></a>
    </li>
    <li class="post-copyright-date">
      <strong><%= __('copyright.date') %> </strong></a>
      <a href="/archives" target="_blank" title="發(fā)布時間: <%= page.date.format("YYYY-MM-DD  HH:MM")%>"><%= page.date.format("YYYY-MM-DD  HH:MM")%></a>
    </li>
    <li class="post-copyright-license">
      <strong><%= __('copyright.license_title') %>  </strong>
      <%- _p('copyright.license_content', '<a rel="license"  target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">CC BY-NC-ND 4.0</a>') %>
    </li>
  </ul>
</div>

Step 3. 在/layout/common/article.ejs中添加如下內(nèi)容(引入copyright.ejs):

<% const services = has_config('donate') ? get_config('donate') : []; %>
<% if (!index && services.length > 0) { %>
<div class="card">
    <div class="card-content">
        <h3 class="menu-label has-text-centered"><%= __('donate.title') %></h3>
        <div class="buttons is-centered">
            <% for (let service of services) {
                const type = get_config_from_obj(service, 'type');
                if (type !== null) { %>
                <%- _partial('donate/' + type, { type, service }) %>
                <% }
            } %>
        </div>
    </div>
</div>
<% } %>


+ <% if (!index && page.copyright){ %>
+ <%- partial('copyright') %>
<% } %>


<% if (!index && (post.prev || post.next)) { %>
<div class="card card-transparent">
    <div class="level post-navigation is-flex-wrap is-mobile">
        <% if (post.prev){ %>
        <div class="level-start">
            <a class="level level-item has-link-grey <%= !post.prev ? 'is-hidden-mobile' : '' %> article-nav-prev" href="<%- url_for(post.prev.path) %>">
                <i class="level-item fas fa-chevron-left"></i>
                <span class="level-item"><%= post.prev.title %></span>
            </a>
        </div>
        <% } %>
        <% if (post.next){ %>
        <div class="level-end">
            <a class="level level-item has-link-grey <%= !post.next ? 'is-hidden-mobile' : '' %> article-nav-next" href="<%- url_for(post.next.path) %>">
                <span class="level-item"><%= post.next.title %></span>
                <i class="level-item fas fa-chevron-right"></i>
            </a>
        </div>
        <% } %>
    </div>
</div>
<% } %>

最后打開你的博客,大功告成。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容