Ghost 0.7.2 with public API

The Ghost folks recently published 0.7.2 including public API features. They’re still in beta which is why you have to activate them in the labs section of your Ghost admin.

For those who've been waiting for the {{#get}} helper, this release is your first chance to start playing with it.

Indeed we like to play with it. Since this blog has switched from WordPress to Ghost in February, I was about to add some archives and tag list pages. But without plugins (called apps in the ghost universe) and API there hasn’t been a proper chance to implement these kind of pages.

Now it is. Find them using the menu button top right!

Look, new navigation and content pages!


Okay, how to use the {{get}} helper?

First up, check out the full get helper documentation.

This is the complete relevant source for our archives page:

{{#get "posts" order="published_at desc" limit="all" include="author,tags" as |articles pages|}}

  <ul class="archive-list">

    {{#foreach articles}}

      <li class="archive-list__item">

        <article class="post">
          <header class="post-header">
            <h2 class="post-title"><a href="{{url}}">{{{title}}}</a></h2>
          </header>
          <footer class="post-meta">
            {{#if author.image}}<a href="{{@blog.url}}/author/{{author.slug}}"><img class="author-thumb" src="{{author.image}}" alt="{{author.name}}" nopin="nopin"/></a>{{/if}}
            {{author}}
            {{tags prefix=" on "}}
            <time class="post-date" datetime="{{date format='YYYY-MM-DD'}}">{{date format="DD MMMM YYYY"}}</time>
          </footer>
        </article>

      </li>

    {{/foreach}}

  </ul>

  <p>{{pages.total}} Posts</p>

{{/get}}

Query for the tags page:

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

Query for the about page including author list:

{{#get "users" limit="all" include="count.posts" order="count.posts desc"}}

Query for featured posts:

{{#get "posts" order="published_at desc" limit="all" include="author,tags" filter="featured:true" as |articles|}}

Thank you, Ghost dev team!