Sign in

Little trick code

#927
Tomasz Dziuda

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

🙂

--
Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!