美文网首页
文章加密TEST2

文章加密TEST2

作者: _danboard | 来源:发表于2018-08-26 09:06 被阅读0次

hexo-blog-encrypt

  1. 安装插件

    $ npm install --save hexo-blog-encrypt
    
  2. 配置

    站点配置文件,添加

    # Security
    ##
    encrypt:
        enable: true
    

    文章头部:

    ---
    title: 标题
    date: 时间
    tags: 标签
    password: 密码
    abstract: 文章摘要,显示在博客首页
    message: 密码输入框上面的描述性文字
    ---
    
  3. 自定义

    • 对TOC加密

      <% if(post.toc == true){ %>
          <div id="toc-div" class="toc-article" <% if (post.encrypt == true) { %>style="display:none" <% } %>>
              <strong class="toc-title">Index</strong>
              <% if (post.encrypt == true) { %>
                  <%- toc(post.origin, {list_number: true}) %>
              <% } else { %>
                  <%- toc(post.content, {list_number: true}) %>
              <% } %>
          </div>
      <% } %>
      <%- post.content %>
      
    • 修改加密模板

      # Security
      ##
      encrypt:
          enable: true
          default_abstract: the content has been encrypted, enter the password to read.
          default_message: Please enter the password to read.
          default_template:
                          <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
                          <div id="security">
                              <div class="input-container">
                                  <input type="password" class="form-control" id="pass" placeholder=" {{message}} " />
                                  <label for="pass"> {{message}} </label>
                                  <div class="bottom-line"></div>
                              </div>
                          </div>
                          <div id="encrypt-blog" style="display:none">
                              {{content}}
                          </div>
      
    • 自定义

      文章头部

      ---
      title: hello world
      date: 2016-03-30 21:18:02
      tags:
          - fdsfadsfa
          - fdsafsdaf
      password: Mike
      abstract: Welcome to my blog, enter password to read.
      message: Welcome to my blog, enter password to read.
      template:
              <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
              <div id="security">
                  <div class="input-container">
                      <input type="password" class="form-control" id="pass" placeholder=" {{message}} " />
                      <label for="pass"> {{message}} </label>
                      <div class="bottom-line"></div>
                  </div>
              </div>
              <div id="encrypt-blog" style="display:none">
                  {{content}}
              </div>
      ---
      

相关文章

网友评论

      本文标题:文章加密TEST2

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