|
2 | 2 | Get post description or generate it from the post content.
|
3 | 3 | {%- endcomment -%}
|
4 | 4 |
|
5 |
| -{%- assign max_length = include.max_length | default: 200 -%} |
6 |
| - |
7 | 5 | {%- capture description -%}
|
8 |
| -{%- if post.description -%} |
9 |
| - {{- post.description -}} |
10 |
| -{%- else -%} |
11 |
| - {% comment %} |
12 |
| - Remove the line number of the code snippet. |
13 |
| - {% endcomment %} |
14 |
| - {% assign content = post.content %} |
| 6 | + {%- if post.description -%} |
| 7 | + {{- post.description -}} |
| 8 | + {%- else -%} |
| 9 | + {% comment %} |
| 10 | + Remove the line number of the code snippet. |
| 11 | + {% endcomment %} |
| 12 | + {%- assign content = post.content -%} |
15 | 13 |
|
16 |
| - {% if content contains '<td class="rouge-gutter gl"><pre class="lineno">' %} |
17 |
| - {% assign content = content | replace: '<td class="rouge-gutter gl"><pre class="lineno">', '<!-- <td class="rouge-gutter gl"><pre class="lineno">'%} |
18 |
| - {% assign content = content | replace: '</td><td class="rouge-code">', '</td> --><td class="rouge-code">' %} |
19 |
| - {% endif %} |
| 14 | + {%- if content contains '<td class="rouge-gutter gl"><pre class="lineno">' -%} |
| 15 | + {%- assign content = content | replace: '<td class="rouge-gutter gl"><pre class="lineno">', '<!-- <td class="rouge-gutter gl"><pre class="lineno">' -%} |
| 16 | + {%- assign content = content | replace: '</td><td class="rouge-code">', '</td> --><td class="rouge-code">' -%} |
| 17 | + {%- endif -%} |
20 | 18 |
|
21 |
| - {{- content | markdownify | strip_html | newline_to_br | replace: '<br />', ' ' | strip_newlines -}} |
22 |
| -{%- endif -%} |
| 19 | + {{- content | strip_html | newline_to_br | replace: '<br />', ' ' | strip_newlines -}} |
| 20 | + {%- endif -%} |
23 | 21 | {%- endcapture -%}
|
24 | 22 |
|
25 |
| -{{- description | strip | truncate: max_length | escape -}} |
| 23 | +{%- if include.json -%} |
| 24 | + {%- assign description = description | jsonify -%} |
| 25 | +{%- else -%} |
| 26 | + {%- assign max_length = include.max_length | default: 200 -%} |
| 27 | + {%- assign description = description | strip | truncate: max_length -%} |
| 28 | +{%- endif -%} |
| 29 | + |
| 30 | +{{- description -}} |
0 commit comments