Using get with Ghost Blogs

February 28, 2016 in #Ghost

I love the concept of ghost and it's implementation, but, like many I dislike having to wait for what I see as rather basic features expected of a blogging platform. Thankfully the dev team over at Ghost has released a beta version of the public api, and it's surprisingly easy to use.

They've essentially created a new block element that you can use in a template called get

Here are a few patterns that I've been using to create lists of pages, tag clouds and recent article lists:

List of Pages

Show a list of pages with the same tag, or in other words

{{#get "posts" include="tags" filter="page:true" limit="all"}}
    {{#foreach posts}}
        {{#has tag="tag_of_pages"}}
            <!-- ... show list of pages -->

Tag Cloud

Show a tag cloud, excluding those pages you're using elsewhere:

{{#get "tags" limit="all" include="count.posts" order="count.posts desc" filter = "slug:-tag_of_pages1+slug:-tag_of_pages2"}}
    {{#foreach tags}}
        <a href="/tag/{{slug}}">{{name}}</a>

Recent Posts

Show a list of recent posts:

{{#get "posts" limit="5" order="created_at desc"}}
    {{#foreach posts}}
        <li><a href="{{slug}}">{{title}}</a></li>