Skip to content

Commit d89d6f6

Browse files
committed
post-description.html added
1 parent 865db6f commit d89d6f6

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

_includes/post-description.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{%- comment -%}
2+
3+
Get the post's description or body content.
4+
5+
Arguments:
6+
full_text: If true, return the full content. Default is false.
7+
max_length: The maximum length of the returned content. Default is 200.
8+
{%- endcomment -%}
9+
10+
{%- if post.description and include.full_text != true -%}
11+
{{- post.description -}}
12+
{%- else -%}
13+
{%- comment -%} Remove the line numbers from the code snippet. {%- endcomment -%}
14+
15+
{%- assign content = post.content -%}
16+
17+
{%- if content contains '<td class="rouge-gutter gl"><pre class="lineno">' -%}
18+
{%- assign content = content
19+
| replace: '<td class="rouge-gutter gl"><pre class="lineno">',
20+
'<!-- <td class="rouge-gutter gl"><pre class="lineno">'
21+
-%}
22+
{%- assign content = content | replace: '</td><td class="rouge-code">', '</td> --><td class="rouge-code">' -%}
23+
{%- endif -%}
24+
25+
{%- assign content = content
26+
| markdownify
27+
| strip_html
28+
| newline_to_br
29+
| replace: '<br />', ' '
30+
| strip_newlines
31+
| strip
32+
-%}
33+
34+
{%- unless include.full_text -%}
35+
{%- assign max_length = include.max_length | default: 200 -%}
36+
{%- assign content = content | truncate: max_length -%}
37+
{%- endunless -%}
38+
39+
{{- content -}}
40+
{%- endif -%}

0 commit comments

Comments
 (0)