mirror of
https://gitlab.com/veilid/veilid-dot-com.git
synced 2025-01-30 16:03:25 -05:00
25 lines
1006 B
Twig
25 lines
1006 B
Twig
{#- data -#}
|
|
{% set type = item.section|default('page')|json_encode() %}
|
|
{% set id = item.id|json_encode(constant('JSON_UNESCAPED_SLASHES')) %}
|
|
{% set attributes = {
|
|
'title': item.title|json_encode(constant('JSON_UNESCAPED_UNICODE')),
|
|
'body': item.body|e('html')|json_encode(constant('JSON_UNESCAPED_UNICODE') b-or constant('JSON_UNESCAPED_SLASHES')),
|
|
'date': item.date|date('c')|json_encode(),
|
|
'updated': item.updated|date('c')|json_encode(),
|
|
} %}
|
|
{#- add front matter variables to attributes -#}
|
|
{% set attributes = item.fmvariables|merge(attributes) %}
|
|
{#- encode attributes values to JSON -#}
|
|
{% set attributes = attributes|map((v) => v|json_encode(constant('JSON_UNESCAPED_UNICODE') b-or constant('JSON_UNESCAPED_SLASHES'))) %}
|
|
{
|
|
"type": {{ type }},
|
|
"id": {{ id }}
|
|
{%- if attributes is defined %},
|
|
"attributes": {
|
|
{%- for key, value in attributes ~%}
|
|
"{{ key }}": {{ value }}{% if not loop.last %},{% endif %}
|
|
{% endfor ~%}
|
|
}
|
|
{% endif %}
|
|
}
|
|
{#- /data -#} |