{#- 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 -#}