article.compiled_content
添加文章内容。我在我的博客中使用 hpricot 来仅显示每篇文章的第一段。<% @site.sorted_articles[0, 10].each do |article| %>
<p><strong>
<%= link_to(article[:title], article.path) %> </strong><br/>
<%= article[:created_at] %> <br/>
<%= tags_for(article) %> <br/></p>
<% end %>
Nanoc3::Helpers::Blogging
中有一些方法被称为 articles
和 sorted_articles
(请参见 http://nanoc.stoneship.org/docs/api/3.1/Nanoc3/Helpers/Blogging.html)。include Nanoc3::Helpers::Blogging
在 lib/
目录下创建一个文件,例如 lib/helpers.rb
。
参见 http://nanoc.stoneship.org/docs/4-basic-concepts/#helpers
lib/
目录中没有这样的文件,请创建一个并将上面的行粘贴到该文件中。Nanoc将要求lib/
中的每个文件,因此您可以将其添加到其他文件之一中,也可以创建具有任意名称的另一个文件。 - Koraktor