我只需要显示部分博客文章...以及完整博客文章的“阅读更多”链接。
主页:列出最后 5 篇部分/介绍帖子,并附有“阅读更多”。
这在 Docpad 中可能吗?
Thanks..
May by
getCuttedContent: (content) ->
i = content.search('<!-- Read more -->')
if i >= 0
content[0..i-1]
else
content
hasReadMore: (content) ->
content.search('<!-- Read more -->') >= 0
more
and
<% posts = @getCollection('posts') %>
<% for i in [@[email protected]]: %>
<% document = posts.at(i).toJSON() %>
<article class="post">
<h3><span class="posts_date"><%= @formatDate(document.date) %></span> <a class="post_head" href="<%= document.url %>"><%= document.title %></a></h3>
<div class="post-content"><%- @getCuttedContent(String(document.contentRenderedWithoutLayouts)) %></div>
<% if @hasReadMore(String(document.contentRenderedWithoutLayouts)): %>
<div class="read_more"><a href="<%= document.url %>"><strong>Читать далее →</strong></a></div>
<% end %>
</article>
<% end %>
posts
并添加到帖子
<!-- Read more -->
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)