How to get a single post or page?


#1

I’m looking through the documentation for the get handlebar.

It says: “It can also be used to perform a ‘read’ query that fetches one specific author , post or tag if the relevant resource field - E.g. id or slug is provided as an attribute.”

But I haven’t been able to find any examples for how to do that. If I have turned a post into a page with url “welcome”. How do I specify the syntax for that?


#2

This is how you can get one single page. The slug/url for the page in this case is “landing”.

{{#get "posts" filter="page:true+slug:landing"}}
    {{#foreach posts}}
        {{content}}
    {{/foreach}}
{{/get}}

#3

There’s an example on the linked page:

A basic request for a single post with id of 2, including its related tags and author data, using a block parameter.

{{#get "posts" id="2" include="tags,authors" as |post|}}
    {{#post}}
        {{title}}
    {{/post}}
{{/get}}

This demonstrates the lack of {{#foreach}} and use of the {{#post}} context.