web/_includes/post-description.html
Cotes Chung 0eb7efa7f5
fix(search): avoid missing spaces between paragraphs in search results (#2199)
- Use a common post-snippet for search results to avoid line break issues
- Reduce Jekyll include files to speed up the build
- Remove outdated key from search.json
2025-01-20 21:27:18 +08:00

25 lines
935 B
HTML

{%- comment -%}
Get post description or generate it from the post content.
{%- endcomment -%}
{%- assign max_length = include.max_length | default: 200 -%}
{%- 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 '<td class="rouge-gutter gl"><pre class="lineno">' %}
{% assign content = content | replace: '<td class="rouge-gutter gl"><pre class="lineno">', '<!-- <td class="rouge-gutter gl"><pre class="lineno">'%}
{% assign content = content | replace: '</td><td class="rouge-code">', '</td> --><td class="rouge-code">' %}
{% endif %}
{{- content | markdownify | strip_html | newline_to_br | replace: '<br />', ' ' | strip_newlines -}}
{%- endif -%}
{%- endcapture -%}
{{- description | strip | truncate: max_length | escape -}}