blob: 0e6ece477875a7fea19de9c19983cad5ce317a27 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
{%- macro from_section(section) -%}
{%- set section = get_section(path=section) -%}
{%- for post in section.pages -%}
{%- if not post.draft -%}
{%- set found = true -%}
{
"title": {{ post.title | striptags | json_encode | safe }},
"url": {{ post.permalink | json_encode | safe }},
"meta": {% if post.summary %}
{{- post.summary | striptags | truncate(length=150) | json_encode | safe }}
{%- elif post.description %}
{{- post.description | striptags | truncate(length=150) | json_encode | safe }}
{%- elif post.content %}
{{- post.content | striptags | truncate(length=150) | json_encode | safe }}
{%- endif %},
"body": {{ post.content | striptags | json_encode | safe }}
}
{%- if not loop.last -%},{%- endif %}
{%- endif -%}
{%- endfor -%}
{%- if found -%}{%- if section.subsections -%}
,
{%- for subsection in section.subsections -%}
{{ self::from_section(section=subsection) }}
{%- endfor -%}
{%- endif -%}{%- endif -%}
{%- endmacro from_section -%}
|