Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

Little trick code

#927
Avatar photo[anonymous]

Hi,

I think that it is a bad idea by default to use handlebars to handle the NEW badge, because it causes that if your website won’t be updated for  a long time, the very old posts will be marked as “NEW”.

Please consider such case:

  1. Add to your post items attribute e.g. data-publish-date – put on this attribute date attribute: https://getpublii.com/dev/date-helper/
  2. The attribute should contain date timestamp – you can achieve this using “x” as a date format: https://momentjs.com/docs/#/parsing/string-format/
  3. Then create a script which will compare date timestamp and for posts newer than e.g. 2 weeks will add the “NEW” badge

🙂