I don’t know if this is a bug or a misconfiguration, but I’m trying to replicate the prev_post
helper with #get
, but I don’t have the results I expect…
I want to extend the prev_post
helper for a use case not supported by prev_post
, but first, I need to make sure I’m able to achieve the same results. I’ve been banging my head against the wall for a few hours…
Is there something I did wrong?
Steps to Reproduce
- Create
partials/prev_post.hbs
with content below - Create
partials/next_post.hbs
with content below - Inside
post.hbs
, include the previous partials{{> prev_post }}{{> next_post }}
- Create and publish empty posts
- First post
- Second post
- Third post
- For each post, check if the partials returns the expected results
Code for partials/prev_post.hbs
{{#get "posts"
filter="slug:-{{slug}}+published_at:<='{{published_at}}'"
include="author,authors,tags,tiers"
limit="1"
order="published_at asc"
as |previousPost|
}}
{{#previousPost}}
<a href="{{url}}">
<section>
<h5>A || {{t "Older Post"}}</h5>
<h3>{{title}} [{{published_at}}]</h3>
</section>
</a>
{{/previousPost}}
{{/get}}
{{#prev_post}}
<a href="{{url}}">
<section>
<h5>B || {{t "Older Post"}}</h5>
<h3>{{title}} [{{published_at}}]</h3>
</section>
</a>
{{/prev_post}}
Code for partials/next_post.hbs
{{#get "posts"
filter="slug:-{{slug}}+published_at:>'{{published_at}}'"
include="author,authors,tags,tiers"
limit="1"
order="published_at desc"
as |nextPost|
}}
{{#nextPost}}
<a href="{{url}}">
<section class="prev-next-title">
<h5>C || {{t "Newer Post"}}</h5>
<h3>{{title}} [{{published_at}}]</h3>
</section>
</a>
{{/nextPost}}
{{/get}}
{{#next_post}}
<a href="{{url}}">
<section>
<h5>D || {{t "Newer Post"}}</h5>
<h3>{{title}} [{{published_at}}]</h3>
</section>
</a>
{{/next_post}}
Expected results
- First post (C = D)
- Previous post: none
- Next post: Second post
- Second post (A == B and C == D)
- Previous post: first post
- Next post: Third post
- Third post (A == B)
- Previous post: Second post
- Next post: none
Current results
- First post (A should be null AND C is null)
- Previous post: Second post
- Next post: none
- Second post (A == B AND C is null)
- Previous post: First post
- Next post: none
- Third post (A == B)
- Previous post: First post
- Next post: none
Setup information
Ghost Version
4.47.1
Node.js Version
v14.19.1
How did you install Ghost?
*Docker *
Provide details of your host & operating system
Docker on Windows 10
Database type
SQLite 3