Hi. I discovered via this forum that shortcodes and macros had been replaced with components. (I use the 0.23.3 version on GNU/Linux Void Linux)
But on the main documentation ( Redirect ), I didn’t find any explanation about it : how to construct it, how to insert it in markdown. What it produces in HTML.
I found a link shared by @keats to the github with a sum of components, but I couldn’t find any example of integration in markdown (neither in the Tera documentation).
I tried to create a component to calculate age like the following :
{% set birthdate = config.extra.birthdate %}
{% set parts = birthdate | split(pat="-") %}
{% set birth_year = parts[0] | int %}
{% set birth_month = parts[1] | int %}
{% set birth_day = parts[2] | int %}
{% set now_year = now() | date(format="%Y") | int %}
{% set now_month = now() | date(format="%m") | int %}
{% set now_day = now() | date(format="%d") | int %}
{% set a = now_year - birth_year %}
{% if now_month < birth_month or (now_month == birth_month and now_day < birth_day) %}
{% set a = a - 1 %}
{% endif %}
{{- a -}}
I tried to insert it in markdown content with the following, found somewhere else in the forum :
{{<age birthdate="1990-01-01" />}}
But it produces a <p> element, unfortunately : it breaks the text line where I want to insert it…
Does it is any other way to insert it, for example in a text line (something like “I’m XX years old.”)
Also, does anyone have a link of a complete documentation about components ? What we can do, how we do it, how to access to config.extra variables, etc. ?
Thanks in advance