Boo Boo - 4 months ago 39
Node.js Question

Ghost filter posts by tag = slug name

I'm writing a theme and I want to get all post tagged with the slug of any specific page by default

like myblog/page1
will return all post taged page1

when i do

{{#get "posts" filter="tags:page1" order="slug asc"}}
{{#foreach posts}}
<p>{{@number}}" </p>
{{/foreach}}
{{/get}}


I get my post and everything is fine

but when I add the #post context to get the tag dynamically it doesn't work

I have tried :

{{#post}}
{{#get "posts" order="slug asc"}}
{{#foreach posts}}
{{#has tag=@slug}}
<p>{{@number}}" </p>
{{/has}}
{{/foreach}}

{{/get}}
{{/post}}


and

{{#post}}
{{#get "posts" filter="tags:@slug" order="slug asc"}}
{{#foreach posts}}
<p>{{@number}}" </p>
{{/foreach}}
{{/get}}
{{/post}}


without any success.

Any help would be appreciated

Boo Boo
Answer

Ok everyone, actually it's pretty simple

{{#post}}
{{#get "posts" filter="tags:{{slug}}" order="slug asc"}}
    {{#foreach posts}}
      <p>{{@number}}" </p>
    {{/foreach}}
{{/get}}
{{/post}}

in the post context , use the slug of the post , only trick is to put handlebars inside handlebars