I’m using Ghost’s built-in timeago=true
to display relative timestamps for my blog posts. However, timeago
continues showing “X days ago” indefinitely, even for older posts.
I want to modify the behavior so that:
- For posts less than 7 days old → Show “5 minutes ago”, “3 days ago”, etc.
- For posts older than 7 days → Display a normal formatted date (e.g., “Feb 10, 2024”).
Currently, I am using this in my theme:
<time class="card-post-date" datetime="{{date format="YYYY-MM-DDTHH:mm:ss"}}">
{{date published_at timeago=true}}
</time>
I tried using conditional Handlebars helpers like {{#if}}
, but since Ghost does not support direct date comparisons (gt
, lt
), I couldn’t get it to work.