1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-08-07 08:51:24 +00:00
jekyll-theme-chirpy/_includes/post-description.html
2025-07-26 20:22:30 +08:00

31 lines
1.1 KiB
HTML

{%- 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 '<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 | strip_html | newline_to_br | replace: '<br />', ' ' | 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 -}}