gpt4 book ai didi

ruby /纳米 : How do I get a list of items to display in a page?

转载 作者:数据小太阳 更新时间:2023-10-29 08:01:54 24 4
gpt4 key购买 nike

我完全承认我是Ruby newb,这个问题可能只是出于我对 Ruby 的无知。

也就是说,我开始使用 nanoc project (并且喜欢它)。我想用这个来增强我的博客...但是:对于我的生活,我无法弄清楚如何获得要在主页上显示的文章/帖子列表。我该怎么做?

如果可能,我想使用 erb/html。

最佳答案

这里有一些 erb,它创建了一个包含 10 篇最新文章的列表,其中包含标题、日期和链接。您还可以使用 article.compiled_content 添加文章内容。我使用 hpricot 只显示我的 blog 中每篇文章的第一段

<% @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 %>

关于 ruby /纳米 : How do I get a list of items to display in a page?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4919336/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com