{%- comment -%} Get post description or generate it from the post content. {%- endcomment -%} {%- capture description -%} {%- if post.description -%} {{- post.description -}} {%- else -%} {% comment %} Remove the line number of the code snippet. {% endcomment %} {%- assign content = post.content -%} {%- if content contains '
' -%}
{%- assign content = content | replace: '', '' -%}
{%- endif -%}
{{- content | strip_html | newline_to_br | replace: '
', ' ' | strip_newlines -}}
{%- endif -%}
{%- endcapture -%}
{%- if include.json -%}
{%- assign description = description | jsonify -%}
{%- else -%}
{%- assign max_length = include.max_length | default: 200 -%}
{%- assign description = description | strip | truncate: max_length -%}
{%- endif -%}
{{- description -}}