LoginSignup
0
0

More than 5 years have passed since last update.

Clipkitの記事に公開日時をもとにNEWを付ける方法

Last updated at Posted at 2018-07-13

公開日時が3日以内の記事の例

現在時刻から3日前の時刻を変数に保存しておく:

{% assign time_3days_ago = 'now' | date: '%s' | minus:259200 | plus:0 %}

比較して記事の公開日時(article.published_at)の方が大きければNEWを付ける:

{% assign time_published = article.published_at | date: '%s' | plus:0 %}
{% if time_published > time_3days_ago %}
<span>NEW</span>
{% endif %}

1日:86400
3日:259200
7日:604800

更新日時と比較したい場合は、published_atをupdated_atにしてください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0