Querying current month? #3119
-
Hi. I want to be able to query the current month globally across the project from either a template or individual file. I started by creating a simple shortcode to get the current month.
I can use this in any template (nunjucks) like so I tried ...
but this didn't work. Any ideas how I might solve this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Rather than add this as a shortcode, I've added a utils.js in the _data folder and can now access getMonth like ... {{ utils.getMonth() }}
// so...
{% if utils.getMonth() == 'December' %}Do December stuff{% else %}Seasonal stuff{% endif %}
Cushty. |
Beta Was this translation helpful? Give feedback.
Rather than add this as a shortcode, I've added a utils.js in the _data folder and can now access getMonth like ...
Cushty.