【发布时间】:2015-10-08 19:12:04
【问题描述】:
如何在首页顶部显示精选帖子? 接下来是其余的帖子。
目前它们显示在分页每一页的顶部。
这是我的 loop.hbs:
{{! Previous/next page links - only displayed on page 2+ }}
<div class="extra-pagination inner">
{{pagination}}
</div>
{{! This is the post loop - each post will be output using this markup }}
{{#foreach posts}}
{{#if featured}}
<article class="{{post_class}} featured">
<header class="post-header">
<h2 class="post-title"><a href="{{url}}">{{{title}}}</a></h2>
</header>
<section class="post-excerpt">
<p>{{excerpt words="26"}} <a class="read-more" href="{{url}}">»</a></p>
</section>
<footer class="post-meta">
{{#if author.image}}<img class="author-thumb" src="{{author.image}}" alt=" {{author.name}}" nopin="nopin" />{{/if}}
{{author}}
{{tags prefix="on"}}
<time class="post-date" datetime="{{date format='YYYY-MM-DD'}}">{{date format="DD MMMM YYYY"}}</time>
</footer>
</article>
{{/if}}
{{/foreach}}
{{! This is the post loop - each post will be output using this markup }}
{{#foreach posts}}
{{#unless featured}}
<article class="{{post_class}}">
<header class="post-header">
<h2 class="post-title"><a href="{{url}}">{{{title}}}</a></h2>
</header>
<section class="post-excerpt">
<p>{{excerpt words="26"}} <a class="read-more" href="{{url}}">»</a></p>
</section>
<footer class="post-meta">
{{#if author.image}}<img class="author-thumb" src="{{author.image}}" alt=" {{author.name}}" nopin="nopin" />{{/if}}
{{author}}
{{tags prefix="on"}}
<time clas s="post-date" datetime="{{date format='YYYY-MM-DD'}}">{{date format="DD MMMM YYYY"}}</time>
</footer>
</article>
{{/unless}}
{{/foreach}}
{{! Previous/next page links - displayed on every page }}
{{pagination}}
这是我的博客:http://netsca.pe/
目前唯一的专题文章是如何在 AWS 上安装 Ghost | Amazon EC2 免费 - 完整指南。
如您所见,它显示在帖子第三页的顶部,而不是首页的顶部。
我读过Stack Overflow: newest post with specific tag on the front page,但还是不明白。
还阅读了此内容:The Ghost Blogging Support Forum: Show Featured post first on index page ,但仍无处可去。
【问题讨论】:
-
我知道它可能看不到太多帮助,但您是否尝试过注释掉 {{pagination}} 只是为了看看它是否真的会首先列出特色文章?我在我的身上试过这个,没问题。我试图将其固定在代码中,但我认为分页是按日期顺序对文章进行排序,因此您的特色帖子位于第 3 页。
-
我确实得到了完全相同的结果,只是没有顶部和底部的“较新”按钮、“Y 页 X”文本和“较旧”按钮。
标签: handlebars.js ghost-blog ghost