{#- Índice de busca do site inteiro (artigos + páginas institucionais/autores/seções).
   "type" identifica o tipo de conteúdo para os filtros da página de busca. -#}
{%- set type_labels = {
  item: 'Artigo',
  category: 'Editoria',
  'section-links': 'Seção',
  institutional: 'Página',
  about: 'Página',
  author: 'Autor',
  videos: 'Vídeos',
  contact: 'Contato'
} -%}
{%- set out = [] -%}
{%- set all = page.collection({'items': '@root.descendants', 'order': {'by': 'date', 'dir': 'desc'}}) -%}
{% for it in all %}{% if it.published and type_labels[it.template] is defined %}
{%- set out = out|merge([{
  title: it.title,
  url: it.url,
  type: it.template,
  type_label: type_labels[it.template],
  editoria: it.parent and it.parent.template == 'category' ? it.parent.title : '',
  date: it.date|date('d.m.Y'),
  summary: it.header.summary ?? it.header.description ?? '',
  author: (it.header.taxonomy.author[0] ?? it.header.role ?? '')|replace({'-': ' '})|title,
  tags: it.header.taxonomy.tag ?? [],
  text: it.content|striptags|trim|slice(0, 600)
}]) -%}
{% endif %}{% endfor %}
{{ out|json_encode(constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_UNESCAPED_UNICODE'))|raw }}
