1

我的问题。

我正在使用 Ghost JS 创建一个博客,并且在home.hbs页面中,我需要包含两个单独的摘要列表,其中包含我博客中发布的最后一篇文章。第一个列表应显示n1标记为 tag 的最后帖子,t1而第二个列表将显示n2标记为 tag 的最后帖子t2。例如应该n1=8 t1=book代表get last 8 published books in my blogn2=3 t2=songget last 3 published songs in my blog

我的方法。

由于我不确定我的问题是否可以通过上下文和帮助程序以声明方式解决,所以我正在尝试激活 Beta 功能,并且我正在使用 ghost 提供的 REST API。我已阅读 API 文档,但我不知道应该如何表达我的查询。我正在检查如下查询,但在表达过滤条件时失败(只获取那些标记为 的帖子T):

jQuery(document).ready(function () {
    $.get(
       ghost.url.api('posts', {
          limit: '3',
          include: 'tags, author',
          filter: 'tags:song', // ???
          order: 'count.posts DESC'
       })
    ).done(onSuccess);
});

我的问题。

我的问题是双重的。有什么方法可以解决我的问题,可以通过上下文和助手以声明性的方式解决它吗?如果没有,我应该如何在 API 的 AJAX 调用中对我的查询进行编码,以获取最后N带有 tag 标记的帖子T

4

1 回答 1

4

您也许可以使用新的 {{get}} 助手。

https://themes.ghost.org/docs/get

这些方面的东西适用于标签云。

{{#get "tags" limit="3" include="count.posts" order="count.posts desc"}}

至于带有标签的帖子,您可以这样做。

{{#get "posts" limit="3" include="tags, author" filter="tag:song"}}

于 2016-01-20T00:47:47.760 回答