【问题标题】:Secure part of Octopress保护 Octopress 的一部分
【发布时间】:2013-02-04 19:41:59
【问题描述】:

我有一个 Octopress 网页,我想使用我通过电子邮件传播的密码(或其他内容)阻止某些帖子(一些只有我的家人才能看到的帖子)。

实现这一点并确保帖子不会出现在存档中的最佳方法是什么?

【问题讨论】:

    标签: ruby security passwords jekyll octopress


    【解决方案1】:

    对于家庭帖子,您可以将它们放在单独的目录中,并使用.htaccess 密码保护该目录。

    为了使它们不显示在档案中,您需要编辑主题。 以下基于经典主题:

    编辑档案/index.html

    ---
    layout: page
    title: Blog Archive
    footer: false
    ---
    
    <div id="blog-archives">
    {% for post in site.posts reverse %}
        {% if  post.categories contains 'noarchive' %}
        {% else %}
            {% capture this_year %}{{ post.date | date: "%Y" }}{% endcapture %}
            {% unless year == this_year %}
                {% assign year = this_year %}
                <h2>{{ year }}</h2>
            {% endunless %}
            <article>
                {% include archive_post.html %}
            </article>
        {% endif %}
    {% endfor %}
    </div>
    

    在您不想在存档中显示的帖子中,yaml 部分看起来像这样:

    ---
    layout: post
    title: "Welcome"
    date: 2013-02-07 00:00
    comments: true
    categories: 
     - site
     - noarchive
    ---
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-01
      • 2021-06-08
      • 2011-05-08
      • 1970-01-01
      • 2011-01-23
      • 1970-01-01
      • 1970-01-01
      • 2022-08-24
      相关资源
      最近更新 更多